Description
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?
My Solution
class Solution:
def climbStairs(self, n: int) -> int:
array = [0] * 46
array[1] = 1
array[2] = 2
for i in range(3, 46):
array[i] = array[i - 1] + array[i - 2]
return array[n]
문제 출처 : https://leetcode.com/problems/climbing-stairs/
'Algorithm > Daily Coding Tests Challenge' 카테고리의 다른 글
[Leetcode] Easy: Pascal's Triangle 2 (0) | 2021.10.10 |
---|---|
[Leetcode] Easy : Pascal's Triangle (0) | 2021.10.10 |
[Leetcode] Median : Find First and Last Position of Element in Sorted Array (0) | 2021.10.09 |
[Leetcode] Hard : Median of Two Sorted Array (0) | 2021.10.09 |
[Leetcode] Medium : Search in Rotated Sorted Array (0) | 2021.10.09 |