usageLimits
array in non-decreasing order.total
to 0, which will keep track of the total number of elements used so far.count
to 0, which will represent the number of groups formed.usageLimits
array.
a. Add the current element to total
.
b. Check if total
is at least as large as the sum of integers from 1 to count + 1
(inclusive).
c. If the condition is met, increment count
.count
as the maximum number of groups that can be formed.