https://leetcode.com/problems/climbing-stairs/

 

Climbing Stairs - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

아직 이게  피보나치 수열 문제라는 것이 딱 와 닿지 않지만

일단 풀어 보았다.

class Solution:
    def climbStairs(self, n: int) -> int:
        if(n == 0):
            return 0
        if(n == 1):
            return 1
        
        dp = []
        dp.append(0)
        dp.append(1)
        dp.append(2)
        
        for i in range(3, n+1):
            dp.append(dp[i-1] + dp[i-2])
        
        return dp[n]

 

 

Posted by 공놀이나하여보세
,