leetcode Climbing Stairs python

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
原文地址:https://www.cnblogs.com/allenhaozi/p/4934969.html