Car Pooling Problem
Car Pooling Problem — ExecCode Medium DSA Practice
Solve the Car Pooling problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
A car has a fixed capacity and only drives east, picking up and dropping off passengers along numbered points. Given trips where trips[i] = [numPassengers, from, to], return true if it is possible to complete every trip without exceeding capacity at any point.
Examples
Input trips = [[2, 1, 5], [3, 3, 7]], capacity = 4; Output false. Input trips = [[2, 1, 5], [3, 3, 7]], capacity = 5; Output true. Input trips = [[3, 2, 7], [3, 7, 9], [8, 3, 9]], capacity = 11; Output true
Constraints
1 ≤ trips.length ≤ 1000 trips[i].length == 3 1 ≤ numPassengers ≤ 100 0 ≤ from < to ≤ 1000 0 ≤ capacity ≤ 10⁵
Practice Car Pooling free on ExecCode. Browse DSA problems, topic map, and placement guides.