public class Solution { public int jumpFloor(int target) { if(target <= 2) return target ; int dp[] = new int[2] ;//dp[i]前i个台阶有多少种跳法 int l_l = 0 ; int l = 1 ; dp[l_l] = 1 ; dp[l] = 2 ; for(int i = 2 ; i < target ; i ++) { dp[(l + 1) % 2] = dp[l] + dp[l_l] ; l = (l + 1) % 2 ; l_l = (l_l + 1) % 2 ; } return dp[l] ; } }