题解 | #跳台阶扩展问题#
跳台阶扩展问题
http://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387
DP问题:f(n) = 2f(n-1)
public class Solution { public int jumpFloorII(int target) { int result = 0; int[] dp = new int[2]; dp[0] = 1; if (1 == target) { return 1; } for(int i = 1; i < target; i++) { result = 2 * dp[0]; dp[0] = result; } return result; } }