Climbing Stairs
Problem: Climbing Stairs
The number of solutions of climbing n stairs is actually decided by the solutions of climbing n-1 stairs and n-2 stairs.
Code in Python:
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
dp = [1, 1]
for i in xrange(2, n+1):
dp.append(dp[i-2]+dp[i-1])
return dp[n]