1. 程式人生 > >LF.391.Determine If Array Is Min Heap

LF.391.Determine If Array Is Min Heap

eterm min nbsp blog HERE RR body clas null

Determine if the given integer array is min heap.

 1 public class Solution {
 2   public boolean isMinHeap(int[] array) {
 3     // Write your solution here
 4     if (array == null || array.length == 0) {
 5         return true ;
 6     }
 7     int pre = array[0] ;
 8     for (int i = 1; i<array.length; i++ ) {
9 if (pre > array[i]) { 10 return false ; 11 } 12 } 13 return true ; 14 } 15 }

LF.391.Determine If Array Is Min Heap