We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 82926b4 commit a9827ceCopy full SHA for a9827ce
250310/LeetCode_875_KokoEatingBananas.java
@@ -0,0 +1,27 @@
1
+class Solution {
2
+ public int minEatingSpeed(int[] piles, int h) {
3
+ int left = 1;
4
+ int right = 0;
5
+
6
+ for (int pile : piles) {
7
+ right = Math.max(right, pile);
8
+ }
9
10
+ while (left <= right) {
11
+ int mid = left + (right - left) / 2;
12
13
+ int count = 0;
14
15
+ count += Math.ceil((double) pile / mid);
16
17
18
+ if (count <= h) {
19
+ right = mid - 1;
20
+ } else {
21
+ left = mid + 1;
22
23
24
25
+ return left;
26
27
+}
0 commit comments