Merge Intervals Problem Statement
You are provided with 'N' intervals, each containing two integers denoting the start time and end time of the interval.
Your task is to merge all overlapping intervals and return the list of merged intervals sorted by increasing order of their start time.
Input:
The first line contains an integer N, representing the number of intervals.
The second line contains N integers, which are the start times of the intervals.
The third line contains N integers, which are the end times of the intervals.
Output:
Print S lines, each containing two space-separated integers A and B, where S is the number of merged intervals,
and A and B are the start and end times of each interval, respectively.
Example:
Input:
N = 5
Start Times = [1, 3, 6, 10, 8]
End Times = [4, 5, 8, 12, 9]
Output:
[1, 5]
[6, 9]
[10, 12]
Constraints:
- 1 ≤ N ≤ 10^5
- 0 ≤ START, FINISH ≤ 10^9
- Time Limit: 1 sec
Note:
You do not need to print anything; it has already been handled. Just implement the function as required.
Be the first one to answer
Add answer anonymously...
Top Cognizant Software Analyst interview questions & answers
Popular interview questions of Software Analyst
Top HR questions asked in Cognizant Software Analyst
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app