Dsa
Intervals
Easy
Longest Network Burst
A network monitor records N periods of 'high latency' as [start, end) timestamps. If two high-latency periods overlap or touch, they merge into a single continuous burst. Find the duration of the longest single continuous burst after merging all overlaps.
Input Format:
The first line contains N.
The next N lines each contain two integers: start and end.
Output Format:
Print the length of the longest merged interval.
Example:
Input:
4
10 15
14 20
25 30
5 8
Output:
10
Explanation: [10,15) and [14,20) overlap to form [10,20) (length 10). Other intervals are [25,30) (length 5) and [5,8) (length 3). Max is 10.
Key concepts
intervalsmergesorting
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