Skip to content

Practice Fair Distribution of Cookies

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

Medium#2305
LeetCode Problem

Fair Distribution of Cookies

Problem Statement

You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up. The unfairness of a distribution is defined as the maximum total cookies obtained by a single child in the distribution. Return the minimum unfairness of all distributions.

Source: Fair Distribution of Cookies on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
cookies = [8,15,10,20,8], k = 2
Output
31

# Example 2

Input
cookies = [6,1,3,2,2,4,1,2], k = 3
Output
7

Constraints

2 <= cookies.length <= 8
1 <= cookies[i] <= 10^5
2 <= k <= cookies.length

Related LeetCode Problems

Practice more problems similar to Fair Distribution of Cookies.

Review your practice with PhantomCodeAI

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