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.

AnswerBot
4mo
Merge overlapping intervals and return sorted list of merged intervals by start time.
Iterate through intervals and merge overlapping ones
Sort merged intervals by start time
Return the sorted list of me...read more
Help your peers!
Add answer anonymously...
Cognizant Software Analyst interview questions & answers
A Software Analyst was asked Q. Can you explain the projects you have worked on?
A Software Analyst was asked Q. Bottom View of Binary Tree Given a binary tree, determine and return its bottom ...read more
A Software Analyst was asked Q. DFS Traversal Problem Statement Given an undirected and disconnected graph G(V, ...read more
Popular interview questions of Software Analyst
A Software Analyst was asked Q1. Can you explain the projects you have worked on?
A Software Analyst was asked Q2. Bottom View of Binary Tree Given a binary tree, determine and return its bottom ...read more
A Software Analyst was asked Q3. DFS Traversal Problem Statement Given an undirected and disconnected graph G(V, ...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

