Title description
A frog can jump up to one step at a time, or up to two steps at a time. Find the total number of jumping methods for the frog to jump on an n-level step (different order counts as different results).
Example 1
enter
1
return value
1
Example 2
enter
4
return value
5
Code implementation :
public class Solution {
public int JumpFloor(int target) {
if (target <= 2) {
return target;
}
int one = 1;
int two = 2;
int tmp = 0;
for (int i = 3; i <= target; i++) {
tmp = one + two;
one = two;
two = tmp;
}
return two;
}
}