Question bank › Intervals
Dsa Intervals Easy

Merge Overlapping Timestamps

You are tasked with managing a logging system that records timestamps of actions. Each log entry has a start and end time indicating when an action began and when it finished. Write a program that merges overlapping log entries into consolidated intervals. Input: - The first line of input contains an integer n (1 <= n <= 1000), the number of log entries. - The next n lines each contain two integers, start and end, representing the start and end of a log entry (0 <= start < end <= 10000). Output: - Print the merged intervals in ascending order, each interval on a new line, formatted as "start end" without quotes. Example Input: 3 1 3 2 4 5 8 Example Output: 1 4 5 8

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.