数学问题,一行代码即可

易知

f(n)=f(n-1)+f(n-2)+……f(1)
f(n-1)=f(n-2)+……f(1)

两式相减得

f(n)=2f(n-1)

f(1) = 1

所以

f(n) = pow(2, n - 1)

由此得出:

public class Solution {
  public int JumpFloorII(int target) {
    return target <= 0 ? 0 : 1 << (target - 1);
  }
}