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
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.