diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/1137. N-th Tribonacci Number.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/1137. N-th Tribonacci Number.java" new file mode 100644 index 00000000..fcbd10b6 --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/1137. N-th Tribonacci Number.java" @@ -0,0 +1,18 @@ +class Solution { + public int tribonacci(int n) { + if(n == 0) return 0; + if(n < 3) return 1; + + int[] tri = new int[n+1]; + + tri[0] = 0; + tri[1] = 1; + tri[2] = 1; + + for(int i=3; i<=n; i++) { + tri[i] = tri[i-1] + tri[i-2] + tri[i-3]; + } + + return tri[n]; + } +} \ No newline at end of file