Merge Overlapping Intervals Problem Statement

Given a specified number of intervals, where each interval is represented by two integers denoting its boundaries, the task is to merge all overlapping intervals and return the list of merged intervals sorted in ascending order of their starting times.

Explanation:

Two intervals are considered overlapping if the starting integer of one interval is less than or equal to the finishing integer of the other interval, and greater than or equal to the starting integer of the same interval.

Input:
Number of test cases, T Each test case includes: N - the number of intervals, followed by two lines: the starting integers and the ending integers of each interval.
Output:
For each test case, output the merged intervals, each on a new line, with intervals represented by two space-separated integers denoting the start and end times.
Example:
Given the intervals: [1,4], [3,5], [6,8], [10,12], [8,9] Merge as follows: [1,4] overlaps [3,5] to form [1,5], [6,8] overlaps [8,9] to form [6,9]. Non-overlapping interval: [10,12] Result: [1,5], [6,9], [10,12]

Constraints:

  • 1 <= T <= 100
  • 1 <= N <= 1000
  • 0 <= start, finish <= 109

Note: Implement the function to handle the merging of intervals as specified.

AnswerBot
4mo

Merge overlapping intervals and return sorted list of merged intervals.

  • Iterate through intervals and merge overlapping ones

  • Sort merged intervals based on starting times

  • Handle edge cases like empty inp...read more

Help your peers!
Select
Add answer anonymously...

Qualcomm Software Developer interview questions & answers

A Software Developer was asked Q. Design and implement a hash map data structure.
A Software Developer was asked Q. How can you swap two numbers without using a third variable?
A Software Developer was asked Q. What is a function pointer in C?

Popular interview questions of Software Developer

A Software Developer was asked Q1. Design and implement a hash map data structure.
A Software Developer was asked Q2. Tell me more about your domain knowledge of the ARM processor architecture.
A Software Developer was asked Q3. How can you swap two numbers without using a third variable?
Qualcomm Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits