Longest free time slot
Your workday runs from minute day_start to minute day_end. meetings is an unsorted list of [start, end] pairs occupying half-open spans [start, end), all within the day, possibly overlapping. Return the length of the longest uninterrupted free stretch in your day, or 0 if there is none. Example: a 0-480 day with meetings [[60,120],[240,300]] gives 180 (minutes 300 to 480).
Implement
longest_free_gap(meetings: list[list[int]], day_start: int, day_end: int) → intExamples
in
[[[60,120],[240,300]],0,480]out180What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 12 min
solution.py
InputExpectedGot
[[[60,120],[240,300]],0,480]180not run yetsample