【剑指offer】变态跳台阶(python)
动态规划,跳上n阶台阶可以从n-1跳1,也可以从n-2跳2,。。。
f(n)=f(n-1)+f(n-2)+...+f(0)
其实就是算了一个等比数列。
# -*- coding:utf-8 -*- class Solution: def jumpFloorII(self, number): # write code here dp = [1 for i in range(number)] for i in range(1,number): for j in range(0,i): dp[i]+=dp[j] return dp[number-1]