Skip to content

Practice Minimum Number of Groups to Create a Valid Assignment

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

Medium#2910
LeetCode Problem

Minimum Number of Groups to Create a Valid Assignment

Problem Statement

Partition all numbered balls into nonempty boxes. Every box must contain only one number, but the same number may occur in several boxes. The ball counts of any two boxes may differ by at most 1. Return the minimum number of boxes satisfying both rules.

Source: Minimum Number of Groups to Create a Valid Assignment on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
balls = [3,2,3,2,3]
Output
2

# Example 2

Input
balls = [10,10,10,3,1,1]
Output
4

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Minimum Number of Groups to Create a Valid Assignment.

Review your practice with PhantomCodeAI

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