class Solution:
def canCompleteCircuit(self, gas, cost):
# 记录总 gas 能不能支持全部旅程、当前 gas、起始站
total = 0
in_tank = 0
start = 0
for i in range(len(gas)):
total += gas[i] - cost[i]
in_tank += gas[i] - cost[i]
# 重置起点位置
if in_tank < 0:
start = i + 1
in_tank = 0
return start if total >= 0 else -1