Today I learned
2022/02/09
회고록
항해 99, 알고리즘 4주차(항해 5주차)
교재 : 파이썬 알고리즘 인터뷰 / 이것이 코딩테스트다(동빈좌)
다이나믹 프로그래밍
이론 정리 포스팅 글(내 벨로그)
You are climbing a staircase. It takes n steps to reach the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example 1:
Input: n = 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
https://leetcode.com/problems/climbing-stairs/
n = 4
d = [0]*(n+1)
d[0]=1
d[1]=1
for i in range(2,n+1):
d[i] = d[i-2] + d[i-1]
print(f'{d[n]}')
DP 알고리즘 익히기