Trains the technique from
LeetCode 2790Maximum Number of Groups With Increasing LengthThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A store holds parts of several kinds, and stock[i] is how many parts of kind i it holds.
Fill a run of batches so that no batch holds two parts of the same kind, no kind is drawn on more times across all the batches than the store holds, and each batch after the first holds strictly more parts than the one before it.
Return the greatest number of batches that can be filled.
Example 1
Three batches need one, two and three parts, six in all. The batch of three takes one part of each kind, the batch of two takes one of the first kind and one of the second, and the batch of one takes another of the first kind. A fourth batch would need four different kinds and only three exist.
Example 2
Only two kinds exist, so no batch can hold three parts without repeating a kind, which caps the run at a batch of one and a batch of two.
Example 3
One kind means no batch can hold two parts, so a single batch of one part is all there is, however many parts the store holds.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_increasing_groups(stock: list[int]) -> int:public int maxIncreasingGroups(int[] stock)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.