Baseline Heaps · Learning O(n) · O(1) iterative / O(log n) recursion depth
A garage stores vehicles in an array layout where slot i's children sit at fixed positions 2i+1 and 2i+2, and the garage rules demand that every occupied parent outrank its children. After reshuffling, an auditor must verify the layout still honors the hierarchy — walking each parent and comparing it against whichever children actually exist.
Input: An integer array A representing the layout.
Output: Return true if A satisfies the binary max-heap property, false otherwise.
1 <= A.length <= 10^5-10^9 <= A[i] <= 10^9Input: {"A":[90,15,10,7,12,2]}
Output: true
Every parent (90, 15, 10) is strictly greater than its existing children.
Input: {"A":[9,15,10,7,12,11]}
Output: false
The root 9 is smaller than its child 15, violating the hierarchy at the first slot.