def betterFib(n):
    """
    Better implementation of nth Fibonacci number generator
    Time complexity - O(n)
    Space complexity - O(n)
    :param n: The nth term
    :return: The nth fibonnaci number
    """
    fib = [None] * n
    #print fib
    if n == 0:
        return 0
    elif n == 1:
        return 1
    elif fib[n-1] is not None:
        return fib[n-1]
    else :
        fib[n-1] = betterFib(n-1) + betterFib(n-2)
        return fib[n-1]