TikTok Interview Question: Can Attend All Intervals (Detect Overlapping Intervals)

13 Views
No Comments

TikTok is hosting a livestream event with popular creators. Each creator has submitted their preferred start time and end time for their part in the livestream. Only one creator can livestream at the event at a time.

Given an array of available time intervals where intervals[i] = [start(i), end(i)], determine if all creators could attend all.

Constraints:

  1. 0 <= start(i) < end(i) <= 10^6
  2. Length of each interval will be 2
Example 1:Input:
intervals = [[0,30],[5,10],[15,20]]Output:
false
Example 2:Input:
intervals = [[7,10],[2,4]]Output:
true

This problem asks whether a set of time intervals can be scheduled without any overlaps. A straightforward approach is to sort the intervals by start time and then scan through them, checking whether the current interval starts before the previous one ends. If any overlap is detected, it’s impossible for all creators to attend without conflict. The logic is simple but tests your understanding of interval ordering and boundary conditions.

END
 0