Leetcode 1013 Solution

This article provides solution to leetcode question 1013 (fibonacci-number)

https://leetcode.com/problems/fibonacci-number

Solution

class Solution:
    def fib(self, n: int) -> int:
        if n == 0:
            return 0
        elif n == 1:
            return 1

        a = 0
        b = 1

        for i in range(1, n):
            a, b = b, a + b

        return b