items. Distribute all of its elements into rows so that:
- every element of items goes into exactly one row;
- no row contains the same value twice;
- the number of rows is as small as possible.
Rows may have different lengths. Return the resulting list of rows. The order of the rows and the order of numbers within a row do not matter.items=[2, 5, 2, 1, 5, 2] → [[2, 5, 1], [2, 5], [2]]
The value 2 appears three times, so at least three rows are needed, for example [2, 5, 1], [2, 5], [2].
items=[3, 1, 2] → [[3, 1, 2]]
All values are distinct, so a single row is enough.
items=[1, 1] → [[1], [1]]
items=[2, 5, 2, 1, 5, 2]
[[2, 5, 1], [2, 5], [2]]
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.