Question
A car drives east along a number line and can carry at most `capacity` passengers. You are given `trips` where trips[i] = [num_passengers, from, to] (the car picks up num_passengers at `from` and drops them at `to`, with from < to). Return True if it is possible to complete every trip without ever exceeding capacity. There are up to 1000 trips and locations up to 1000; use a difference array over locations and a prefix sweep, not per-trip recomputation.
car_pooling(trips: list[list[int]], capacity: int) → bool[[[2,1,5],[3,3,7]],4]outfalseState your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.