Maximum Candies Allocated to K Children

Medium · Binary Search · about 20 minutes

Asked at Google, Amazon, Microsoft, Oracle, Bloomberg, IBM, Morgan Stanley.

There are piles of candy; pile i holds candies[i] pieces. You may break any pile into smaller piles, but piles can't be combined. Every one of k children must receive exactly one pile, and all those piles must be equal in size. What is the largest size you can give each child? Return 0 if it can't be done.

Related guides