题解 | #斐波那契数列#
斐波那契数列
https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3
#不要用递归 递归速度太慢
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param n int整型
# @return int整型
#
def f(l, n):
for i in range(n - 2):
l.append(l[-1] + l[-2])
return l[-1]
class Solution:
def Fibonacci(self , n: int) -> int:
# write code here
print(f([1,1],n))
return f([1,1],n)


查看21道真题和解析