题解 | #跳台阶扩展问题#
跳台阶扩展问题
http://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387
f(n) = f(n-1)+f(n-2).....+f(1)+f(0) f(0)=1 f(n-1) = f(n-2)+f(n-3)+f(n-4).....+f(1)+f(0) 上面两个式子相减 f(n)=2*f(n-1)
public class Solution {
public int jumpFloorII(int target) {
if(target == 1){
return 1;
}
return 2*jumpFloorII(target-1);
}
}