Climbing Stairs-python

来源:互联网 发布:买一个域名多少钱 编辑:程序博客网 时间:2024/06/08 17:59
class Solution(object):    def climbStairs(self,n):        """        :param n: int        :return: int        """        t=[1,1]        i=2        if n>=2:            while i<=n:                t.append(t[i-1]+t[i-2])                i=i+1        return t[-1]p=Solution()print p.climbStairs(5)
0 0