Time Interval Merger
Hard
intervals
sorting
merging
Problem Description
Given a list of time intervals, merge all overlapping intervals and return the merged intervals sorted by start time.
Input Format
First line contains n (number of intervals). Next n lines contain two integers each representing start and end time of an interval.
Output Format
Print merged intervals, one per line, with start and end time separated by space
Constraints
1 ≤ n ≤ 1000, 0 ≤ start < end ≤ 10000
Sample Input/Output
Input:
4 1 3 2 6 8 10 15 18
Output:
1 6 8 10 15 18
Explanation
Intervals [1,3] and [2,6] overlap, so they merge to [1,6]
Solution Hints
- Read carefully: Understand input/output format and constraints
- Start simple: Think of brute force solution first, then optimize
- Edge cases: Consider empty inputs, single elements, max constraints
- Data structures: Choose arrays, hash maps, sets based on problem needs
- Time complexity: Ensure your solution fits within time limits
- Test examples: Verify logic with provided sample inputs
250
Points
Points
2000ms
Time Limit
Time Limit
256MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now