LeetCode70爬楼梯

未经博主同意,禁止瞎JB转载。

LeetCode70爬楼梯

https://leetcode-cn.com/problems/climbing-stairs/description/

斐波那契数列

动态规划

我的解法:

 1 class Solution(object):
 2     def climbStairs(self, n):
 3         """
 4         :type n: int
 5         :rtype: int
 6         """
 7         ret = [0,1]
 8         for i in range(n):
 9             ret.append(ret[0]+ret[1])
10             ret.pop(0)
11         return ret[-1]

 

posted @ 2018-10-11 21:16  嬴政有条北冥的鱼  阅读(69)  评论(0编辑  收藏  举报