limits of length n. Build several groups out of the numbers 0 to n - 1 so that:
- no number repeats inside a group;
- every group is strictly longer than the one before it;
- number i appears at most limits[i] times across all groups.
Return the largest number of groups you can build.limits=[3, 1, 2] → 3
Groups [0], [0, 2], [0, 1, 2]: number 0 is used three times, 1 once and 2 twice, and the sizes grow 1 → 2 → 3.
limits=[1, 1, 1, 1] → 2
Each number is available once, so for example [0] and [1, 2] work. Only number 3 remains for a third group, which would need three numbers.
limits=[6] → 1
limits=[3, 1, 2]
3
Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.