일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- data science
- DWG
- Substring with Concatenation of All Words
- attribute
- kaggle
- LeetCode
- 43. Multiply Strings
- 파이썬
- Regular Expression
- concurrency
- Convert Sorted List to Binary Search Tree
- 시바견
- 밴픽
- Python
- Python Implementation
- iterator
- Decorator
- Protocol
- 운영체제
- Python Code
- 109. Convert Sorted List to Binary Search Tree
- 715. Range Module
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- 프로그래머스
- Class
- Generator
- 컴퓨터의 구조
- t1
- shiba
Archives
- Today
- Total
Scribbling
LeetCode: 96. Unique Binary Search Trees 본문
Computer Science/Coding Test
LeetCode: 96. Unique Binary Search Trees
focalpoint 2021. 10. 13. 20:58class Solution:
def numTrees(self, n: int) -> int:
dp = [0] * (n+1)
dp[0] = 1
dp[1] = 1
for i in range(2, n+1):
count = 0
for j in range(1, i+1):
count += dp[j-1] * dp[i-j]
dp[i] = count
return dp[n]
'Computer Science > Coding Test' 카테고리의 다른 글
프로그래머스: 주식 가격 (0) | 2021.10.16 |
---|---|
프로그래머스: 다리를 지나는 트럭 (0) | 2021.10.15 |
LeetCode: 95. Unique Binary Search Trees II (0) | 2021.10.13 |
LeetCode: 92. Reverse Linked List II (0) | 2021.10.12 |
LeetCode: 97. Interleaving String (0) | 2021.10.11 |