https://leetcode.com/problems/climbing-stairs/
class Solution:
def climbStairs(self, n: int) -> int:
dp = [j for j in range(n+1)]
for i in range(3, n+1):
dp[i] = dp[i-1] + dp[i-2]
return dp[n]
Bottom-up 방식으로 설계
피보나치 문제와 비슷함
'알고리즘 > LeetCode' 카테고리의 다른 글
[LeetCode/C++]FirstBadVersion _ binary search (0) | 2021.10.05 |
---|---|
[LeetCode/python]4. Median of Two Sorted Arrays (0) | 2021.10.03 |
[LeetCode]N-th Tribonacci Number/ DP문제 (0) | 2021.10.01 |