码迷,mamicode.com
首页 > 其他好文 > 详细

LF.391.Determine If Array Is Min Heap

时间:2018-04-01 10:39:40      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:OLE   smi   []   style   bsp   span   ++   gpo   SM   

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

标签:OLE   smi   []   style   bsp   span   ++   gpo   SM   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!