low through high inclusive. The occupied seats are listed in taken, which is sorted ascending, has no repeats and stays within those bounds.
Return the free seats as the fewest possible ranges [a, b] (seats a through b inclusive). The ranges must be in ascending order, must not touch any occupied seat, and together must cover every free seat.taken=[3, 4, 9], low=1, high=12 → [[1, 2], [5, 8], [10, 12]]
The free numbers are 1–2, 5–8 and 10–12.
taken=[], low=-5, high=5 → [[-5, 5]]
Nothing is taken, so the whole range is one stretch.
taken=[6, 7, 8], low=6, high=8 → []
Everything is taken, so there are no free stretches.
taken is strictly increasingtaken=[3, 4, 9], low=1, high=12
[[1, 2], [5, 8], [10, 12]]
Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.