原题地址

 

基本动归题

可以压缩状态空间

 

代码:

 1 int climbStairs(int n) {
 2         if (n <= 0)
 3             return 0;
 4             
 5         int count = 1;
 6         int tmp = 1;
 7         
 8         for (int i = 2; i <= n; i++) {
 9             int t = count;
10             count += tmp;
11             tmp = t;
12         }
13         
14         return count;
15 }

 

相关文章:

  • 2021-10-29
  • 2021-10-21
  • 2021-12-08
  • 2021-10-08
  • 2022-12-23
猜你喜欢
  • 2021-07-23
  • 2021-08-06
  • 2022-01-04
  • 2022-01-27
  • 2022-01-27
  • 2021-09-29
  • 2021-10-05
相关资源
相似解决方案