package leetcode;

/**
 * https://leetcode.com/problems/koko-eating-bananas/
 */
public class Problem875 {
    public int minEatingSpeed(int[] piles, int H) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem875 prob = new Problem875();
        System.out.println(prob.minEatingSpeed(new int[]{3, 6, 7, 11}, 4)); // 11
        System.out.println(prob.minEatingSpeed(new int[]{3, 6, 7, 11}, 5)); // 7
        System.out.println(prob.minEatingSpeed(new int[]{3, 6, 7, 11}, 6)); // 6
        System.out.println(prob.minEatingSpeed(new int[]{3, 6, 7, 11}, 7)); // 6
        System.out.println(prob.minEatingSpeed(new int[]{3, 6, 7, 11}, 8)); // 4
        System.out.println(prob.minEatingSpeed(new int[]{3, 6, 7, 11}, 100)); // 1
        System.out.println(prob.minEatingSpeed(new int[]{30, 11, 23, 4, 20}, 5)); // 30
        System.out.println(prob.minEatingSpeed(new int[]{30, 11, 23, 4, 20}, 6)); // 23
    }
}

@@ -164,794 +164,607 @@
     
-// TODO%0A        return 
+int lo = 1;%0A        int hi = 1_000_00
 0;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem875 prob = new Problem875();%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B3, 6, 7, 11%7D, 4)); // 11%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B3, 6, 7, 11%7D, 5)); // 7%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B3, 6, 7, 11%7D, 6)); // 6%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B3, 6, 7, 11%7D, 7)); // 6%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B3, 6, 7, 11%7D, 8)); // 4%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B3, 6, 7, 11%7D, 100)); // 1%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B30, 11, 23, 4, 20%7D, 5)); // 30%0A        System.out.println(prob.minEatingSpeed(new int%5B%5D%7B30, 11, 23, 4, 20%7D, 6)); // 23
+while (lo %3C= hi) %7B%0A            int mid = (lo + hi) / 2;%0A            int time = time(piles, mid);%0A            if (time %3C= H) %7B%0A                hi = mid - 1;%0A            %7D else %7B%0A                lo = mid + 1;%0A            %7D%0A        %7D%0A        return lo;%0A    %7D%0A%0A    private static int time(int%5B%5D piles, int val) %7B%0A        int time = 0;%0A        for (int pile : piles) %7B%0A            int div = pile / val;%0A            int mod = pile %25 val;%0A            if (mod %3E 0) %7B%0A                div++;%0A            %7D%0A            time += div;%0A        %7D%0A        return time;
 %0A   

Solve problem 875