Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Groups to Create a Valid Assignment

Minimum Number of Groups to Create a Valid Assignment asks you to divide an array into groups of identical values, with group sizes differing by at most one, and return the minimum count.

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

Minimum Number of Groups to Create a Valid Assignment asks you to divide an array into groups of identical values, with group sizes differing by at most one, and return the minimum count.

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