Maximum Candies For Children In D Days
Max Candies Problem: Find max candies that can be allocated to kids from same lot, given candies array and number of kids. Use binary search to find optimal solution.
Problem //same as coco eating bananas, //capacity to ship packages within d days //aggresive cows class Solution { public int maximumCandies(int[] candies, long k) { long sum = 0; int max = 0; for(int i : candies){ sum+=i; max = Math.max(max, i);//max no. of candy that can be allocated to child from the same lot } if(sum<k) return 0; int low =1;// lowest no. of candy that can be allocated to child from the same lot int high = max; while(low<=high){ int mid = (low+high)/2; if(is...