题解 | #跳台阶#
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
class Solution {
public:
int jumpFloor(int number) {
if(number <= 2){
return number;
}
int n_2 = 1;
int n_1 = 2;
int res;
for(int i=3; i<=number; i++){
res = n_1 + n_2;
n_2 = n_1;
n_1 = res;
}
return res;
}
};


查看18道真题和解析