Wins the offer-09 level jump metamorphosis

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);
    }
};
Published 29 original articles · won praise 4 · Views 7602

Guess you like

Origin blog.csdn.net/qq_36400206/article/details/104284262