Dsa
Intervals
Easy
Event Scheduling
You are given a list of events, where each event is defined by its start and end times. Your task is to consolidate overlapping events into a single event that spans the earliest start time to the latest end time of the overlapping events. The input format consists of two lines: the first line contains the integer n (the number of events), and the second line contains n pairs of integers representing the start and end times of each event. Output the consolidated list of events as pairs of start and end times. Each pair should be printed on a new line. Example: Input: 5
1 3
2 4
5 7
6 8
9 10
Output: 1 4
5 8
9 10
Key concepts
intervalssortinggreedy
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