Time limit: 1 second to space constraints: 32768K heat index: 452,462
Title Description
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).
Thinking: n-th order before a jump only two possibilities, either the first n-1, either the n-2, so f (n) = f (n-1) + f (n-2);
solution1:
1 class Solution { 2 public: 3 int jumpFloor(int number) { 4 if(number==1||number ==2)return number; 5 return jumpFloor(number-1)+jumpFloor(number-2); 6 } 7 };
Thoughts: recursion is very simple, find DP solution if that is positive to come and also no difference.