# 剑指offer-JZ9

https://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387?tpId=13&tqId=11162&rp=1&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking&tab=answerKey

c++

```class Solution {
public:
int jumpFloorII(int number) {
if (number ==0 || number==1) return 1;
vector<int> f(number+1, 0);
f[0]=1;
f[1]=1;
for (int i =2; i<=number; i++){
for (int j=0; j<i; j++){
f[i]=f[i]+f[j];
}
}
return f[number];
}
};```

```class Solution {
public:
int jumpFloorII(int number) {
if(number == 0 || number == 1) return 1;
int ans=1;
for(int i=2; i<=number; i++){
ans = ans << 1;
}
return ans;
}
};```

```class Solution {
public:
int jumpFloorII(int number) {
if(number == 0 || number == 1) return 1;
return pow(2,number-1);
}
};```

```class Solution {
public:
int jumpFloorII(int number) {
if (number ==0 || number ==1) return 1;
int ans = 0;
while(number>=0){
number--;
ans = ans + jumpFloorII(number);
}
return ans;

}
};```

```class Solution {
public:
int Fib(int n, vector<int> &dp){
if (n==0 ||n==1) return 1;
if (dp[n] != 0) return dp[n];
int temp =n;
while(temp>=0){
temp--;
dp[n]= dp[n] + Fib(temp, dp);
}
return dp[n];
}
int jumpFloorII(int number) {
vector<int> dp(number+1, 0);
return Fib(number, dp);
}
};```

```class Solution {
public:
int jumpFloorII(int number) {
if(number == 0 || number == 1) return 1;
return jumpFloorII(number-1)*2;
}
};```