Skip to content

Practice Maximum Candies Allocated to K Children

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2226
LeetCode Problem

Maximum Candies Allocated to K Children

Problem Statement

You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two piles together. You are also given an integer k. You should allocate piles of candies to k children such that each child gets the same number of candies. Each child can be allocated candies from only one pile of candies and some piles of candies may go unused. Return the maximum number of candies each child can get.

Source: Maximum Candies Allocated to K Children on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
candies = [5,8,6], k = 3
Output
5

# Example 2

Input
candies = [2,5], k = 11
Output
0

Constraints

1 <= candies.length <= 10^5
1 <= candies[i] <= 10^7
1 <= k <= 10^12

Related LeetCode Problems

Practice more problems similar to Maximum Candies Allocated to K Children.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.