:type gas: List[int] :type cost: List[int] :rtype: int
(self, gas, cost)
| 67 | """ |
| 68 | class Solution(object): |
| 69 | def canCompleteCircuit(self, gas, cost): |
| 70 | """ |
| 71 | :type gas: List[int] |
| 72 | :type cost: List[int] |
| 73 | :rtype: int |
| 74 | """ |
| 75 | if sum(gas) < sum(cost): |
| 76 | return -1 |
| 77 | |
| 78 | rest = 0 |
| 79 | station = None |
| 80 | |
| 81 | for i in range(len(gas)): |
| 82 | if rest + gas[i] - cost[i] >= 0: |
| 83 | rest = rest + gas[i] - cost[i] |
| 84 | if station is None: |
| 85 | station = i |
| 86 | else: |
| 87 | rest = 0 |
| 88 | station = None |
| 89 | |
| 90 | return station |
| 91 |
nothing calls this directly
no outgoing calls
no test coverage detected