Skip to content

Commit f2dc01f

Browse files
authored
Create 1137. N-th Tribonacci Number (#464)
2 parents a3cd72a + 1f8b6f3 commit f2dc01f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

1137. N-th Tribonacci Number

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int tribonacci(int n) {
4+
vector<int>temp={0,1,1};
5+
int var=0;
6+
for(int i=3;i<n+1;++i){
7+
var=temp[i-1]+temp[i-2]+temp[i-3];
8+
temp.push_back(var);
9+
}
10+
return temp[n];
11+
}
12+
};

0 commit comments

Comments
 (0)