# Leetcode 875. Koko Eating Bananas ###### tags: `Leetcode(JAVA)` 題目 : https://leetcode.com/problems/koko-eating-bananas/ 。 想法 : 二分搜。 時間複雜度 : O(logn)。 程式碼 : (JAVA) ``` class Solution { public int minEatingSpeed(int[] piles, int h) { int low = 1, high = 1000000000, mid = 0; while (low <= high) { mid=(low+high)/2; int tmp = 0; for(int i=0 ; i<piles.length ; i++){ tmp+=Math.ceil(1.0 * piles[i] / mid); } if(tmp>h){ low=mid+1; } else{ high=mid-1; } } return low; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up