Shuttle capacity feasibility
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) → boolExamples
in
[[[2,1,5],[3,3,7]],4]outfalseWhat 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.
0:00 of about 25 min
solution.py
InputExpectedGot
[[[2,1,5],[3,3,7]],4]falsenot run yetsample