일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Python
- 밴픽
- attribute
- t1
- 시바견
- Python Code
- Substring with Concatenation of All Words
- 운영체제
- Class
- DWG
- Protocol
- 43. Multiply Strings
- Decorator
- 프로그래머스
- 715. Range Module
- LeetCode
- 315. Count of Smaller Numbers After Self
- Regular Expression
- Python Implementation
- 30. Substring with Concatenation of All Words
- 파이썬
- 컴퓨터의 구조
- data science
- 109. Convert Sorted List to Binary Search Tree
- Convert Sorted List to Binary Search Tree
- shiba
- iterator
- Generator
- kaggle
- concurrency
Archives
- Today
- Total
Scribbling
LeetCode: 122. Best Time to Buy and Sell Stock II 본문
Computer Science/Coding Test
LeetCode: 122. Best Time to Buy and Sell Stock II
focalpoint 2021. 11. 3. 20:20class Solution:
def maxProfit(self, prices: List[int]) -> int:
profit, prev = 0, prices[0]
for i in range(1, len(prices)):
if prices[i] >= prev:
profit += prices[i] - prev
prev = prices[i]
return profit
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 188. Best Time to Buy and Sell Stock IV (0) | 2021.11.04 |
---|---|
LeetCode: 123. Best Time to Buy and Sell Stock III (0) | 2021.11.03 |
LeetCode: 120. Triangle (0) | 2021.11.03 |
LeetCode: 117. Populating Next Right Pointers in Each Node II (0) | 2021.11.03 |
프로그래머스: 징검다리 (0) | 2021.11.03 |