LeetCode 134 Gas Station - Why Naive Fails

The trap

Try starting from each station. Simulate the full journey.

nn stations, each simulation is O(n)O(n). Total: O(n2)O(n^2).

Can you eliminate impossible starting points without full simulation?