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