I was checking around to see different implementations and found this one:

```
class Solution {
public:
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) {
int start = 0, min = 0, sum = 0;
for(int i = 0; i < gas.size(); i++)
{
sum = sum < 0 ? gas[i] - cost[i] : gas[i] - cost[i] + sum;
if(sum < 0) {
min = min < sum ? min : sum;
start = i + 1;
}
}
return start == gas.size() || sum + min < 0 ? -1 : start;
}
};
```

It is accepted but should not pass the following test case, which expects -1. The solution above returns 3.

gas = [99, 98, 97, 100], cost = [100, 100, 100, 97]