Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Gas Station
Bookmark
Input
Example 1
Impossible
Start at 0
Single station
Custom
gas
=
[1, 2, 3, 4, 5]
,
cost
=
[3, 4, 5, 1, 2]
gas
0
1
1
2
2
3
3
4
4
5
cost
3
4
5
1
2
algo
master
.
io
Step:
Start: Find starting gas station to complete circuit
Variable
Value
gas
Array(5) [1, 2, 3...]
cost
Array(5) [3, 4, 5...]
total_tank
-
current_tank
-
Variable
Value
start
-
i
-
return
-
0 / 15
Input
Example 1
Impossible
Start at 0
Single station
Custom
gas
=
[1, 2, 3, 4, 5]
,
cost
=
[3, 4, 5, 1, 2]
0 / 15
gas
0
1
1
2
2
3
3
4
4
5
cost
3
4
5
1
2
algo
master
.
io
Step:
Start: Find starting gas station to complete circuit
Visualization
Variables