일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 프로그래머스
- iterator
- kaggle
- 715. Range Module
- LeetCode
- 109. Convert Sorted List to Binary Search Tree
- 315. Count of Smaller Numbers After Self
- 밴픽
- 시바견
- concurrency
- 30. Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- Protocol
- DWG
- Decorator
- attribute
- t1
- 43. Multiply Strings
- 파이썬
- shiba
- 컴퓨터의 구조
- Python Implementation
- Class
- Convert Sorted List to Binary Search Tree
- Python
- 운영체제
- Regular Expression
- Python Code
- Generator
- data science
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 |