首页 > 其他 > 详细

LF.391.Determine If Array Is Min Heap

时间:2018-04-01 10:30:42      阅读:215      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/davidnyc/p/8685555.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!