1137. N-th Tribonacci Number Easy

@problem@discussion
#Math#Dynamic Programming#Memoization



1/**
2 * [1137] N-th Tribonacci Number
3 *
4 * The Tribonacci sequence Tn is defined as follows: 
5 * 
6 * T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.
7 * 
8 * Given n, return the value of Tn.
9 * 
10 *  
11 * Example 1:
12 * 
13 * 
14 * Input: n = 4
15 * Output: 4
16 * Explanation:
17 * T_3 = 0 + 1 + 1 = 2
18 * T_4 = 1 + 1 + 2 = 4
19 * 
20 * 
21 * Example 2:
22 * 
23 * 
24 * Input: n = 25
25 * Output: 1389537
26 * 
27 * 
28 *  
29 * Constraints:
30 * 
31 * 
32 * 	0 <= n <= 37
33 * 	The answer is guaranteed to fit within a 32-bit integer, ie. answer <= 2^31 - 1.
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/n-th-tribonacci-number/
39// discuss: https://leetcode.com/problems/n-th-tribonacci-number/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn tribonacci(n: i32) -> i32 {
45        0
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_1137() {
57    }
58}
59


Back
© 2025 bowen.ge All Rights Reserved.