Wins the offer-09 level jump metamorphosis
Title Description
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.
Topic category
Fibonacci number
Problem-solving ideas
用数学归纳法证明fn=2^n-1
Implementation
class Solution {
public:
int jumpFloorII(int number) {
if(number <= 0) return 0;
return pow(2,number-1);
}
};