class Solution:
"""
@param n: an integer
@return: an ineger f(n)
"""
def fibonacci(self, n):
# write your code here
res = [0, 1]
for i in range(2, n):
res.append(res[i-1]+res[i-2])
return res[n-1]
Python, LintCode, 366. 斐波纳契数列
最新推荐文章于 2018-06-11 15:45:41 发布