Can one car serve all riders?
Company: Uber
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of interval scheduling and conflict detection, testing skills in time-interval reasoning, sorting, and efficient comparison of ranges.
Constraints
- 0 <= len(intervals) <= 100000
- -1000000000 <= start < end <= 1000000000
Examples
Input: [[1, 3], [3, 5], [6, 8]]
Expected Output: True
Explanation: The first two intervals only touch at time 3, which is allowed. No pair overlaps.
Input: [[1, 4], [2, 5], [6, 7]]
Expected Output: False
Explanation: The intervals [1, 4] and [2, 5] overlap from time 2 to 4.
Input: []
Expected Output: True
Explanation: With no riders, there is no scheduling conflict.
Input: [[5, 7]]
Expected Output: True
Explanation: A single interval can always be served by one car.
Input: [[5, 10], [1, 2], [2, 5], [10, 12]]
Expected Output: True
Explanation: After sorting, the intervals are [1, 2], [2, 5], [5, 10], [10, 12]. They only touch at endpoints, so there is no overlap.
Input: [[-2, 1], [-1, 0], [1, 3]]
Expected Output: False
Explanation: The intervals [-2, 1] and [-1, 0] overlap, so one car is not enough.