题目:
题解:
class Solution:def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int:start, cur_res, total_res = 0, 0, 0for i in range(len(gas)):cur_res += gas[i] - cost[i]total_res += gas[i] - cost[i]if cur_res < 0:cur_res = 0start = i + 1if total_res < 0:return -1else:return start