기억노트

[Leetcode/Python3] 70. Climbing Stairs 본문

Coding Test 준비/Leetcode

[Leetcode/Python3] 70. Climbing Stairs

진바니 2022. 1. 11. 03:20

Code

class Solution:
    def climbStairs(self, n: int) -> int:
        d = [0] * 46
        d[1] = 1
        d[2] = 2
        for i in range(3, n+1):
            d[i] = d[i-1] + d[i-2]
        return d[n]

 

Result

Runtime: 41 ms
Memory Usage: 14.5 MB