일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- kaggle
- Python
- 운영체제
- 315. Count of Smaller Numbers After Self
- 43. Multiply Strings
- 715. Range Module
- 밴픽
- Protocol
- iterator
- attribute
- 파이썬
- 컴퓨터의 구조
- Regular Expression
- shiba
- Substring with Concatenation of All Words
- concurrency
- LeetCode
- 시바견
- 30. Substring with Concatenation of All Words
- Convert Sorted List to Binary Search Tree
- data science
- DWG
- Generator
- Python Code
- 프로그래머스
- Python Implementation
- t1
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- Class
Archives
- Today
- Total
Scribbling
LeetCode: 134. Gas Station 본문
class Solution:
def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int:
culsum = 0
for i in range(len(gas)):
gas[i] -= cost[i]
culsum += gas[i]
if culsum < 0:
return -1
start_idx, culsum = 0, 0
for i in range(len(gas)):
culsum += gas[i]
if culsum < 0:
culsum = 0
start_idx = i + 1
return start_idx
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 155. Min Stack (0) | 2021.11.30 |
---|---|
LeetCode: 152. Maximum Product Subarray (0) | 2021.11.29 |
LeetCode: 150. Evaluate Reverse Polish Notation (0) | 2021.11.26 |
LeetCode: 238. Product of Array Except Self (0) | 2021.11.25 |
LeetCode: 1329. Sort the Matrix Diagonally (0) | 2021.11.24 |