标签:img == print span 技术 pre microsoft alt http
非递归实现。
1 class Solution(object): 2 def fib(self, N): 3 """ 4 :type N: int 5 :rtype: int 6 """ 7 fibs = [] 8 fibs.append(0) 9 fibs.append(1) 10 if N <= 1: 11 return fibs[N] 12 for i in range(2, N + 1): 13 fibs.append(fibs[i - 2] + fibs[i - 1]) 14 return fibs[-1] 15 16 17 if __name__ == ‘__main__‘: 18 solution = Solution() 19 print(solution.fib(0))
标签:img == print span 技术 pre microsoft alt http
原文地址:https://www.cnblogs.com/panweiwei/p/12757690.html