Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Car Pooling

XPChallenge Points: 20
levelLevel: Medium

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.

Example 1:

Input: trips = [[2,1,5],[3,3,7]], capacity = 4

Output: false

Example 2:

Input: trips = [[2,1,5],[3,3,7]], capacity = 5

Output: true

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result