def canCompleteCircuit(gas, cost):

```
for i in range(len(gas)):
gas[i] = gas[i] - cost[i]
sum = 0
i=0
j = 0
for count in range(len(gas)):
if sum>=0:
sum = sum + gas[i]
i = i+1
if sum < 0:
sum = sum + gas[j-1]
j = j-1
if sum>0:
return len(gas) + j if j else 0
else:
return -1
```