Room free windows

Write codeMedium14 minMeta style

Your task

A conference room's bookings for one day are [start, end] pairs occupying half-open spans [start, end), unsorted, possibly overlapping, and all inside the building's open hours [open_time, close_time]. Return the room's free windows within open hours as [start, end] pairs sorted by start, skipping zero-length windows. Example: bookings [[9,10],[12,13]] with hours 8 to 18 give [[8,9],[10,12],[13,18]].

Examples

free_windows(meetings: list[list[int]], open_time: int, close_time: int) -> list[list[int]]
Example 1
Inputfree_windows([[9, 10], [12, 13]], 8, 18)
Output[[8, 9], [10, 12], [13, 18]]