Quant Memo
Coding/●●●●

Split lots into consecutive runs

Asked at Five Rings, IMC

You have a multiset of integer lot sizes and a run length g. Decide whether all of them can be partitioned into groups of exactly g consecutive integers (for example, with g = 3, a group could be 6, 7, 8). Every lot must be used exactly once.

lots = [1, 2, 3, 6, 2, 3, 4, 7, 8], g = 3
-> True            # groups [1,2,3], [2,3,4], [6,7,8]

Return whether such a partition exists. Aim for O(nlogn)O(n \log n).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions