Question bank › Intervals
Dsa Intervals Easy

Merge Time Intervals

Given a list of time intervals represented as pairs of start and end times, merge overlapping intervals into the smallest number of non-overlapping intervals. Each interval is input as two integers separated by space. The output should be a list of merged intervals, where each interval is presented by its start and end times. Input format: - The first line contains a single integer n (1 ≤ n ≤ 100) representing the number of intervals. - Each of the next n lines contains two space-separated integers a and b (0 ≤ a < b ≤ 24) representing an interval [a, b). Output format: - The output should be a list of merged intervals, where each interval is presented as two space-separated integers representing the start and end times of the merged intervals. Example: Input: 3 1 3 2 4 5 7 Output: 1 4 5 7

Key concepts

intervalsmergingsorting

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.