topic Description (1)
A frog can jump up to 1 steps at a time, or jump up to level 2. How many jumps are there in total for the frog to jump up the N-level steps? Topic Description (2)
A frog can jump up to 1 steps at a time, or jump up to level 2 ... It can also jump up n levels. How many jumps are there in total for the frog to jump up the N-level steps? Topic Description (3)
We can cover the larger rectangle with a small rectangular 2*1, either horizontally or vertically. I would like to ask the small rectangle with n 2*1 overlay a 2*n large rectangle without overlapping, how many methods are in total.
public class Solution {//Pass formula Method (1) public int jumpfloor (int target) {if (target<=0) {
return 0;
} if (target==1) {return 1;
} int[]dp=new int[target+1];
Dp[0]=1;
Dp[1]=1;
for (int i=2;i<=target;i++) {dp[i]=dp[i-1]+dp[i-2];
return Dp[target];
}//(2) public int jumpfloorii (int target) {if (target<=0) {return 0;
} if (target==1) {return 1;
} int[]dp=new int[target+1];
Dp[0]=1;
Dp[1]=1;
for (int i=2;i!=target+1;i++) {int temp=i;
while (Temp!=-1) {dp[i]+=dp[temp];
--temp;
} return Dp[target]; }//(3) public int rectcover (int target) {if (target<=0) {return0;
} if (target==1) {return 1;
} if (target==2) {return 2;
} int[]dp=new int[target+1];
Dp[1]=1;
dp[2]=2;
for (int i=3;i!=target+1;i++) {dp[i]=dp[i-1]+dp[i-2];
return Dp[target];
public static void Main (String[]args) {//system.out.println ("Hello"); }
}