Skip to content

Latest commit

 

History

History

1137-N-thTribonacciNumber

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

N-th Tribonacci Number

Problem can be found in here!

Solution: Dynamic Programming

@cache
def tribonacci(self, n: int) -> int:
    if n == 0:
        return 0
    elif n == 1 or n == 2:
        return 1

    return self.tribonacci(n-3) + self.tribonacci(n-2) + self.tribonacci(n-1)

Time Complexity: O(n), Space Complexity: O(n)