Solved LeetCode program · 830 of 1,000
#1094 · Car Pooling
Original English source
The trips is a list of 2, 1, 5, 3, 3, and 7. The capacity is 4. The changes is a list of 1001 zeros.
For every trip from 0 to 1.
The base is trip times 3. The riders is item base of trips. The start is item (base plus 1) of trips. The finish is item (base plus 2) of trips. Increase item start of changes by riders. Decrease item finish of changes by riders.
The current is 0. The overloaded is 0.
For every place from 0 to 1000.
The change is item place of changes. Add change to current. If current is more than capacity, set overloaded to 1.
If overloaded is 1, show false, otherwise show true.
Expected stdout
false