Car Pooling
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A car with capacity empty seats drives east only, never turning back. Each entry trips[i] = [numPassengers, from, to] says that group picks up numPassengers people at kilometer from and drops them all off at kilometer to.
Passengers who get off at kilometer x leave before anyone boarding at x gets on, so a drop-off and pick-up at the same point never overlap.
Return true if every trip can be served without ever having more than capacity passengers in the car, otherwise false.
Examples
Constraints
- 1 <= trips.length <= 1000
- trips[i].length == 3
- 1 <= numPassengers <= 100
- 0 <= from < to <= 1000
- 1 <= capacity <= 10^5
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.