Gas Station
Recognize the pattern
Brute force idea
The naive version of Gas Station sounds like this: Try starting from each station, simulate the journey. Each start simulates the full circuit. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
Better approach
A calmer way to see Gas Station is this: Single pass: track totalTank and currentTank. If currentTank goes negative, the start must be AFTER this point. Reset currentTank and move start to the next station. If totalTank ≥ 0 at the end, the last start position is valid. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
Key invariant
The truth you want to protect throughout Gas Station is this: If the total gas ≥ total cost, a solution exists. If you run out of gas at station i starting from station s, then NO station between s and i can be the start — they'd all run out even sooner. So start from i+1. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
One easy way to drift off course in Gas Station is this: Not understanding why skipping to i+1 is safe — if you can't reach i from s, any station between s and i would have less accumulated fuel at i, so they'd fail too. The fix is usually to return to the meaning of each move, not just the steps themselves.