Code Room
CodingMediumcod-g855
Subject Sweep lineLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

A shuttle with a fixed passenger capacity drives strictly east along a number line, never reversing. You are given trips, each [numPassengers, start, end], meaning that many passengers board at location start and alight at location end (they occupy the vehicle on [start, end)). Return True if it is possible to serve every trip without ever exceeding capacity, otherwise False.

Implement
car_pooling(trips: list[list[int]], capacity: int) → bool
Examples
in[[[2,1,5],[3,3,7]],4]outfalse
What a strong answer looks like

State 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.

Run or narrate your approach, then ask the coach.