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
9d

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!
Add answer anonymously...
Freshworks Senior Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter