Car Pooling
Try to solve the Car Pooling problem.
We'll cover the following
Statement
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]
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:
trips.length
trips[i].length
capacity
Examples
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.