You are given a car with a fixed number of seats, denoted by an integer capacity
. The car only travels in one direction — eastward — and does not make any U-turns.
You are also provided with an array, trips
, where each element trips[i]
=[numPassengersi,fromi,toi] represents a group of numPassengersi that must be picked up at location fromi and dropped off at location toi. All locations are measured in kilometers east of the starting point.
Your task is to determine whether it is possible to complete all the trips without exceeding the car’s capacity at any point in time.
Return TRUE if all trips can be completed successfully, or FALSE otherwise.
Constraints:
1≤ trips.length
≤1000
trips[i].length
==3
1≤numPassengersi≤100
0≤fromi<toi≤1000
1≤ capacity
≤105