Dsa
Sorting
Easy
Event Schedule
You are given a list of events, each represented by a start and end time. Your task is to sort these events by their start times. If two events have the same start time, sort them by their end time.
Input format:
- The first line contains an integer n (1 <= n <= 1000), the number of events.
- Each of the next n lines contains two integers start and end (0 <= start < end <= 24), representing the start and end times of the events.
Output format:
- Print the sorted events, each on a new line in the format: 'start end'.
Example:
Input:
3
9 10
12 14
9 12
Output:
9 10
9 12
12 14
Key concepts
sortingtuplestime
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