HTMLify

LeetCode - Fibonacci Number - Python
Views: 156 | Author: abh
class Solution:
    def fib(self, n: int) -> int:
        if n == 0:
            return 0
        if n == 1:
            return 1
        fibo = [0, 1]
        for _ in range(n-1):
            fibo.append(fibo[-1]+fibo[-2])
        return fibo[-1]

Comments