Approach Summary
If total gas >= total cost, a solution exists. The starting station is where cumulative tank first goes negative (reset there).
How to Recognize This Pattern
- Circular route feasibility
- Reset start on negative tank
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(1)
Tags
Array Greedy