LeetCode刷题_70_爬楼梯
70 爬楼梯
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
dp = []
for i in range(n):
if i == 0:
dp.append(1)
elif i == 1:
dp.append(2)
else:
dp.append(dp[i-1] + dp[i-2])
return dp[-1]
if __name__ == '__main__':
testcase = 3
p
共有 0 条评论