Question bank › Intervals
Dsa Intervals Easy

Interval Merging

You are given a list of intervals represented as pairs of integers [start, end]. Your task is to merge all overlapping intervals and return a list of non-overlapping intervals. The output should be sorted by the starting times of the intervals. Input format: - First line contains an integer n (1 ≤ n ≤ 100): number of intervals. - Next n lines, each containing two integers start and end, separated by a space (0 ≤ start < end ≤ 10^9). Output format: - Print the merged intervals in sorted order. Each interval should be printed on a new line in the format 'start end'. Example: Input: 5 1 3 2 4 5 7 6 8 9 10 Output: 1 4 5 8 9 10

Key concepts

intervalsmergingarray

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.