Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit 7d744e3

Browse files
authored
Merge pull request #560 from Karnak123/1137-N-th-Tribonacci-Number
added solution to leetcode problem 1137
2 parents ec1decc + 5df8927 commit 7d744e3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def tribonacci(self, n: int) -> int:
3+
a, b, c = 0, 1, 1
4+
if n == 0:
5+
return 0
6+
elif n == 1 or n == 2:
7+
return 1
8+
else:
9+
for _ in range(n - 2):
10+
temp = a + b + c
11+
a = b
12+
b = c
13+
c = temp
14+
return temp

0 commit comments

Comments
 (0)