Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Gas Station
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given gas and cost arrays, find the starting gas station index to complete the circuit, or -1 if impossible.
Sample Input:
[1,2,3,4,5], [3,4,5,1,2]
Sample Output:
3
Hints
Hint 1
If total gas < total cost, solution is impossible
Hint 2
Track current tank and starting station
Hint 3
Reset starting station when tank becomes negative
Code Editor
Reset
Run
Save
Loading...