Skip to content

Commit

Permalink
Create 1137-N-th-Tribonacci-Number.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitali-Matteo authored Aug 24, 2022
1 parent 04e4f56 commit 9fa1b5e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/1137-N-th-Tribonacci-Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution:
Memo = {}
def tribonacci(self, n: int):
if n in self.Memo:
return self.Memo[n]
if n == 0:
return 0
if n == 1:
return 1
if n == 2:
return 1
self.Memo[n] = self.tribonacci(n - 1) + self.tribonacci(n - 2) + self.tribonacci(n - 3)
return self.Memo[n]

0 comments on commit 9fa1b5e

Please sign in to comment.