Overlapping Intervals Problem Statement

You are given the start and end times of 'N' intervals. Write a function to determine if any two intervals overlap.

Note:

If an interval ends at time T and another interval starts at the same time, they are not considered overlapping intervals.

Input:

The first line contains an integer 'T', the number of test cases. 
The first line of each test case contains an integer 'N', the number of intervals.
The second line contains 'N' space-separated integers representing the starting times of the intervals.
The third line contains 'N' space-separated integers representing the ending times of the intervals.

Output:

For each test case, return true if there are overlapping intervals, otherwise return false.
Example:
Input: 
T = 2
Test Case 1:
N = 2
Starts = [1, 3]
Ends = [2, 4]
Test Case 2:
N = 2
Starts = [1, 2]
Ends = [2, 3]
Output: 
Test Case 1: True
Test Case 2: False

Constraints:

  • 1 ≤ T ≤ 102
  • 0 ≤ N ≤ 105
  • 0 ≤ Start[i] ≤ 1015
  • 1 ≤ End[i] ≤ 1015
  • Time Limit: 1 sec
AnswerBot
4mo

Determine if any two intervals overlap based on start and end times.

  • Iterate through intervals and check for any overlapping intervals by comparing start and end times.

  • Sort the intervals based on start...read more

Help your peers!
Select
Add answer anonymously...

Freshworks Senior Software Developer interview questions & answers

A Senior Software Developer was asked Q. What is threading, and what are the different scheduling algorithms?
A Senior Software Developer was asked Q. Cube Sum Pairs Problem Statement Given a positive integer N, find the number of ...read more
A Senior Software Developer was asked Q. Middle of Linked List Problem Statement Given the head node of a singly linked l...read more

Popular interview questions of Senior Software Developer

A Senior Software Developer was asked Q1. What is threading, and what are the different scheduling algorithms?
A Senior Software Developer was asked Q2. Cube Sum Pairs Problem Statement Given a positive integer N, find the number of ...read more
A Senior Software Developer was asked Q3. Middle of Linked List Problem Statement Given the head node of a singly linked l...read more
Freshworks Senior 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