[LeetCode][Python3] 134. Gas Station
2019. 4. 8. 02:16 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/gas-station/
My Solution :
class Solution:
def canCompleteCircuit(self, gas, cost):
before = tank = start = 0
for i in range(len(gas)):
tank += (gas[i] - cost[i])
if tank < 0:
before += tank
tank = 0
start = i+1
return start if 0 <= before + tank else -1
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 218. The Skyline Problem (0) | 2019.04.11 |
---|---|
[LeetCode][Python3] 150. Evaluate Reverse Polish Notation (0) | 2019.04.10 |
[LeetCode][Python3] 33. Search in Rotated Sorted Array (0) | 2019.04.10 |
[LeetCode][Python3] 227. Basic Calculator II (0) | 2019.04.09 |
[LeetCode][Python3] 23. Merge k Sorted Lists (0) | 2019.04.07 |
[LeetCode][Python3] 210. Course Schedule II (0) | 2019.04.05 |
[LeetCode][Python3] 148. Sort List (1) | 2019.04.04 |
[LeetCode][Python3] 139. Word Break (0) | 2019.04.03 |
최근에 달린 댓글 최근에 달린 댓글