题目:
代码:
class Solution:
def fib(self, n: int) -> int:
# 思路:动态规划求解
# a, b 初始为0,1
a, b = 0, 1
for _ in range(n):
a, b = b, a+b
return a % 1000000007
class Solution:
def fib(self, n: int) -> int:
# 思路:动态规划求解
# a, b 初始为0,1
a, b = 0, 1
for _ in range(n):
a, b = b, a+b
return a % 1000000007