题解 | #跳台阶#
跳台阶
https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
class Solution { public: int jumpFloor(int number) { int fib[40]={1,1}; for(int i=2;i<=number;++i) { fib[i]=fib[i-1]+fib[i-2]; } return fib[number]; } };
跳台阶
https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
class Solution { public: int jumpFloor(int number) { int fib[40]={1,1}; for(int i=2;i<=number;++i) { fib[i]=fib[i-1]+fib[i-2]; } return fib[number]; } };
相关推荐