动态规划解法:
public int jumpFloor(int target) { //定义dp[n]为跳到第n层的有几种跳法 //且dp[n] = dp[n-1] + dp[n-2]; if (target <= 1) return 1; int[] dp = new int[target + 1]; dp[0] = 1; dp[1] = 1; //控制循环次数和dp数组索引 for (int i = 2; i <= target; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[target]; }