Dsa
Intervals
Easy
The Developer's Silence
A developer has a workday of T minutes (from time 0 to T). They have N scheduled meetings, each represented by [start, end). The developer wants to find the longest continuous block of time available for deep work where no meetings are scheduled. Meetings may overlap.
Input Format: The first line contains T and N. The next N lines contain start and end times.
Output Format: A single integer representing the length of the longest gap.
Example:
Input:
480 2
100 150
200 250
Output:
230
(Gaps are 0-100, 150-200, 250-480. Longest is 230.)
Key concepts
sortinggaps
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now