首页 > 其他 > 详细

Leetcode 70 Climbing Stairs

时间:2016-02-24 10:45:40      阅读:209      评论:0      收藏:0      [点我收藏+]

其实就是斐波那契数列

 1 class Solution {
 2 public:
 3     int climbStairs(int n) {
 4         int f1 = 0;
 5         int f2 = 1;
 6         int f3 = 0;
 7         for(int i = 0; i < n; ++i){
 8             f3 = f2 + f1;
 9             f1 = f2;
10             f2 = f3;
11         }
12         return f3;
13     }
14 };

 

Leetcode 70 Climbing Stairs

原文:http://www.cnblogs.com/onlyac/p/5212106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!