Question bank › Intervals
Dsa Intervals Easy

Merging Event Intervals

You are tasked with managing event schedules for a conference. Given a list of event intervals, where each interval is represented by a start and end time, you need to merge any overlapping intervals into one unified interval. Each interval is defined by two integers, the start and end time, with the start time always less than the end time. The program should read from standard input, where the first line contains an integer n (the number of intervals). The next n lines each contain two space-separated integers representing the start and end times of an interval. Your goal is to print the merged intervals in ascending order of their start times. Input Format: - An integer n (1 ≤ n ≤ 10000) - Followed by n lines, each containing two integers (start, end) (0 ≤ start < end ≤ 10^9) Output Format: - The merged intervals, each represented as "start end" 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

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