自己的解法
class Solution:
def fib(self, n: int) -> int:
f = [0, 1]
if n <= 1:
return f[n]
for i in range(1, n):
f.append(f[i] + f[i-1])
return f[-1]
自己的解法
class Solution:
def fib(self, n: int) -> int:
f = [0, 1]
if n <= 1:
return f[n]
for i in range(1, n):
f.append(f[i] + f[i-1])
return f[-1]