You’re given:
• An integer capacity → total number of seats in the car.
• An array trips, where each trip is represented as [numPassengers, from, to]:
o numPassengers: number of passengers for the trip
o from: pickup location (in km east)
o to: drop-off location (in km east)
The car moves only east — it can’t go back.
Return True if all trips can be completed without exceeding capacity, otherwise False.
Input: trips = [[2,1,5],[3,3,7]], capacity = 4
Output: false
Input: trips = [[2,1,5],[3,3,7]], capacity = 5
Output: true
Accepted:
Submission: