Gas Station
Medium
Arrays
Array
Greedy
Circular route with gas[] and cost[]. Find starting station index or -1.
Constraints
1 ≤ n ≤ 10^5
Examples
Example 1:
Input: 1 2 3 4 5
3 4 5 1 2
Output: 3
Example 2:
Input: 2 3 4
3 4 3
Output: -1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console