Approach Summary
Sort cars by position descending. Each car joins the fleet ahead if its time to reach target is ≥ that car's time.
How to Recognize This Pattern
- "How many groups of cars reach destination together"
- Process right-to-left after sorting
Complexity Analysis
Time Complexity
O(n log n)
Space Complexity
O(n)
Tags
Array Stack Sorting Monotonic Stack