← Back

β›½ Fuel Circuit Challenge

Gas Station - Greedy Start Point

Stations

-

Start Index

-

Current

-

Tank

0

Visited

0
β›½ Tank: 0
Generate a circuit and find valid starting station!

πŸ“– Gas Station

Problem: Find starting station to complete circuit

Greedy Insight: If total gas β‰₯ total cost, solution exists

β€’ Track running tank; if negative, reset start to next station

β€’ Last start point is the answer

Time: O(n) single pass