LeetCode-70-Climbing Stairs DP水题Fibonacci

来源:互联网 发布:造价软件排名 编辑:程序博客网 时间:2024/05/01 08:20


class Solution(object):    def climbStairs(self, n):        """        :type n: int        :rtype: int        """        if n<=1:return 1        a=1        b=1        c=0        for i in range(2,n+1):            c=a+b            a=b            b=c        return c


原创粉丝点击