MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / Solution

Class Solution

DP/ClimbingStairs.py:42–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40https://leetcode.com/problems/climbing-stairs/description/
41"""
42class Solution(object):
43 def climbStairs(self, n):
44 """
45 :type n: int
46 :rtype: int
47 """
48
49 if n < 1:
50 return 0
51
52 if n == 1:
53 return 1
54
55 dp = []
56 dp.append(1)
57 dp.append(2)
58
59 for i in range(2, n):
60 dp.append(dp[i-1]+dp[i-2])
61 return dp[-1]
62

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected