Code Room
CodingEasycod-g1457
Subject IntervalsLevel Entry–Mid~12 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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) → int
Examples
in[[[60,120],[240,300]],0,480]out180
What 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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.