Deviopath › TypeScript

Find Free Time Slots

Hard · Algorithms

Times are "HH:MM" strings (24-hour clock). Write freeSlots(busy, dayStart, dayEnd, minMinutes) that returns the free slots of a day.

- busy ranges can be unsorted, can overlap, and can reach outside the day.

- A free slot is a part of [dayStart, dayEnd] that is not covered by any busy range. Touching ranges (one ends when the next starts) leave no gap.

- Only keep slots that are at least minMinutes long.

- Return them sorted by start time, formatted as "HH:MM" with two digits each.

Next: URL Router with Params