MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / tribonacci

Method tribonacci

1137-n-th-tribonacci-number.rs:16–25  ·  view source on GitHub ↗
(n: i32)

Source from the content-addressed store, hash-verified

14// 动态规划
15impl Solution {
16 pub fn tribonacci(n: i32) -> i32 {
17 let mut ret = vec![0; 38];
18 ret[0] = 0;
19 ret[1] = 1;
20 ret[2] = 1;
21 for i in 3..38 {
22 ret[i] = ret[i-1] + ret[i-2] + ret[i-3];
23 }
24 ret[n as usize]
25 }
26}
27
28fn main() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected