标签:col scribe solution des 青蛙跳 pre 一个 code get
public class Solution { public int JumpFloorII(int target) { if(target<=0){ return -1; }else if(target==1){ return 1; }else{ return 2*JumpFloorII(target-1); } } }
n级台阶,n种跳法:跳1级、跳2级……跳n级
跳1级,剩下n-1级,则剩下跳法是f(n-1)
跳2级,剩下n-2级,则剩下跳法是f(n-2)
……
跳n-1级,剩下1级,则剩下跳法是f(1)
跳n级,剩下0级,则剩下跳法是f(0)
f(n)=f(n-1)+f(n-2)+...+f(1)+f(0)
f(n-1)=f(n-2)+f(n-3)+...+f(1)+f(0)
标签:col scribe solution des 青蛙跳 pre 一个 code get
原文地址:https://www.cnblogs.com/chanaichao/p/10120477.html