leetle

Daily challenge for 2026-07-24

570. Toll Booth Queue Clearance

You are managing a toll booth. The array cars represents the number of cars arriving at the booth at minute 1, 2, ..., n. The toll booth can process up to limit cars per minute. Any cars that cannot be processed wait in a queue for the next minute.

Return the exact minute when the last car passes the toll booth. If no cars ever arrive, return 0.

Example:
Input: cars = [1, 0, 0, 5], limit = 2
Output: 6
Explanation:
- Minute 1: 1 car arrives, 1 passes. Queue: 0.
- Minute 2 & 3: 0 arrive, 0 pass.
- Minute 4: 5 arrive, 2 pass. Queue: 3.
- Minute 5: 0 arrive, 2 pass. Queue: 1.
- Minute 6: 0 arrive, 1 passes. Queue: 0. All clear at minute 6.

Run this challenge interactively in Python or JavaScript when the app loads.