Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Groups to Create a Valid Assignment

med
30 min
Try to solve the Minimum Number of Groups to Create a Valid Assignment problem.

Statement

You are given an integer array balls.

You want to distribute all the elements of balls into groups such that:

  • Every element in the same group has identical values.

  • The difference in size between any two groups is at most 11. That is, there exists a positive integer kk such that each group contains either kk or k+1k + 1 elements.

Return the minimum number of groups required to create a valid assignment.

Constraints:

  • 1≤1 \leq balls.length ≤105\leq 10^5

  • 1≤1 \leq balls[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Groups to Create a Valid Assignment

med
30 min
Try to solve the Minimum Number of Groups to Create a Valid Assignment problem.

Statement

You are given an integer array balls.

You want to distribute all the elements of balls into groups such that:

  • Every element in the same group has identical values.

  • The difference in size between any two groups is at most 11. That is, there exists a positive integer kk such that each group contains either kk or k+1k + 1 elements.

Return the minimum number of groups required to create a valid assignment.

Constraints:

  • 1≤1 \leq balls.length ≤105\leq 10^5

  • 1≤1 \leq balls[i] ≤109\leq 10^9