有一点对数组的用法与Math方法取整用法记录一下吧
class Solution { public int minEatingSpeed(int[] piles, int h) { int left =0; int right = Arrays.stream(piles).max().getAsInt(); while(left < right){ int mid = (left+right)/2; if(check(piles,mid,h)){ right = mid; }else{ left = mid+1; } } return left; } public boolean check(int[] piles,int spead,int h){ int hours = 0; for(int p:piles){ hours += Math.ceil((double)p/spead); } return hours <= h; } }