PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of interval scheduling and conflict detection, testing skills in time-interval reasoning, sorting, and efficient comparison of ranges.

  • medium
  • Uber
  • Coding & Algorithms
  • Data Scientist

Can one car serve all riders?

Company: Uber

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given a list of passenger waiting intervals, determine whether a single car can serve all passengers without any scheduling conflict. Each interval is given as [start, end], where start < end. Assume the car can serve at most one passenger during any time interval, and two intervals that overlap imply a conflict. Intervals that only touch at an endpoint, such as [1, 3] and [3, 5], are not conflicts. Return true if no intervals overlap; otherwise return false.

Quick Answer: This question evaluates understanding of interval scheduling and conflict detection, testing skills in time-interval reasoning, sorting, and efficient comparison of ranges.

You are given a list of passenger service intervals. Each interval is represented as [start, end], where start < end. A single car can serve at most one passenger at any moment in time. If any two intervals overlap, then the car cannot serve all riders. Intervals that only touch at an endpoint, such as [1, 3] and [3, 5], do not overlap and are allowed. Return True if one car can serve every rider without any scheduling conflict; otherwise return False.

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.

Hints

  1. Try arranging the intervals in chronological order before checking for conflicts.
  2. Because touching endpoints is allowed, a conflict only happens when the next interval starts strictly before the previous one ends.
Last updated: Apr 19, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Maximize Throughput and Count Trigger Components - Uber (medium)
  • Replace Dashes With Nearest Letters - Uber (medium)
  • Find Earliest Column With One - Uber (easy)
  • Solve Wonderful Strings and Grid Queries - Uber (hard)
  • Count Islands After Land Additions - Uber (medium)