Question bank › Intervals
Dsa Intervals Medium

Interval Merger

You are given a list of intervals where each interval is represented as a pair of integers. Write a function to merge all overlapping intervals and return a new list of intervals that do not overlap. The function should read from standard input the number of intervals followed by the intervals themselves, and then output the merged intervals. Input Format: - The first line contains an integer N (1 <= N <= 1000), the number of intervals. - The next N lines each contain two integers representing the start and end of an interval. Output Format: - Each merged interval on a new line in the format: start end. Example Input: 4 1 3 2 4 5 7 6 8 Example Output: 1 4 5 8

Key concepts

intervalsmergingalgorithm

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