青蛙跳台阶

dp[n]=dp[n-1]+dp[n-2]

 

class Solution:
    def findways(self,number):
        if number==1 or number ==2:
            return number
        dp=[1,2]
        
    for i in range(number-2):
        dp.append(dp[-1]+dp[-2])
        
    return dp[-1]
        

 

posted @ 2019-01-03 10:11  findtruth123  阅读(183)  评论(1编辑  收藏  举报