A frog can jump on a Class 1 level, you can also hop on level 2 ...... n It can also jump on stage. The frog jumped seeking a total of n grade level how many jumps.
We know that the law is like solving
class Solution {
public:
int jumpFloorII(int number) {
int i = 1;
while(--number)
{
i *= 2;
}
return i;
}
};
A frog can jump on a Class 1 level, you can also hop on level 2. The frog jumped seeking a total of n grade level how many jumps (the order of different calculation different results)
class Solution {
public:
int jumpFloor(int number) {
if(number <= 1)
return 1;
return jumpFloor(number-1)+jumpFloor(number-2);
}
};