Fundamentals/Car Poolingmedium
← PrevNext →
There is a car with capacity empty seats available. The car only drives east (i.e., it cannot turn around and drive west).
You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively.
Return true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.
Example 1
Inputtrips = [[2,1,5],[3,3,7]], capacity = 4
Outputfalse
Example 2
Inputtrips = [[2,1,5],[3,3,7]], capacity = 5
Outputtrue