首页 > 编程语言 > 详细

leetcode Climbing Stairs python

时间:2015-11-04 09:16:20      阅读:225      评论:0      收藏:0      [点我收藏+]
class Solution(object):
    def climbStairs(self, n):
        """
        :type n: int
        :rtype: int
        """
        if n <= 2:
            return n
        last =1
        nexttolast = 1
        sums = 0
        for i in range(2,n+1):
            sums = last+nexttolast
            nexttolast = last
            last = sums
        return sums

 

leetcode Climbing Stairs python

原文:http://www.cnblogs.com/allenhaozi/p/4934969.html

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