Skip to the page

DSA · Build it

Car pooling (LeetCode 1094)

The interviewer asks

A car with capacity C only drives east. Given trips as [passengers, from, to], can it complete all of them?

Then

Follow-ups the interviewer asks next

  1. Return the first location where capacity is exceeded.
  2. Merge overlapping intervals.
  3. Minimum meeting rooms.

The answer

What a strong answer covers

  • a difference array over locations (when the range is bounded), or sorted pickup/drop events with drops first at equal positions; prefix sums compared with C; O(n + range) or O(n log n); the link to meeting rooms and calendar-overlap layouts.

The red pen

Common traps

Avoid:processing a pickup before a drop at the same location; filling every position of every trip (O(n × range)).

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview