```
Input: [1,2,3,3], [2,1,5,1]
Output: 2
Expected: 3
```

Can't I travel from station[2] to the left?

```
from to tank gas cost
2 1 0 3 1
1 0 2 2 2
0 3 2 1 1
3 2 2 3 5 [OK]
```

Thanks Shangrila. The key is "from station `i`

to **its next** station `i + 1`

", but I recommend to add some words to clarify this unidirection circle problem.

My solution

```
class Solution {
public:
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) {
int n = gas.size();
int sumVal = 0, tmpSumVal = 0, maxVal = 0, maxIndex = 0;
for(int i = 0; i < n; ++i){
int val = gas[i] - cost[i];
if(val > maxVal || val == maxVal && tmpSumVal < 0){
maxIndex = i;
maxVal = val;
tmpSumVal = val;
}
sumVal += val;
tmpSumVal += val;
}
return sumVal >= 0 ? maxIndex : -1;
}
};
```