Verify Max Heap
Given a list of integers nums, return whether it represents a max heap. That is, for every i we have that:
nums[i] ≥ nums[2*i + 1]if2*i + 1is within boundsnums[i] ≥ nums[2*i + 2]if2*i + 2is within bounds
Constraints
0 ≤ n ≤ 100,000wherenis the length ofnums
https://binarysearch.com/problems/Verify-Max-Heap
Examples
Example 1
Input
- nums = 
[4, 2, 3, 0, 1] 
Output
- answer = 
True 
      
      
Leave a comment