题目:
题解:
func canCompleteCircuit(gas []int, cost []int) int {for i, n := 0, len(gas); i < n; {sumOfGas, sumOfCost, cnt := 0, 0, 0for cnt < n {j := (i + cnt) % nsumOfGas += gas[j]sumOfCost += cost[j]if sumOfCost > sumOfGas {break}cnt++}if cnt == n {return i} else {i += cnt + 1}}return -1
}