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

Method fib_dp

509-fibonacci-number.rs:18–25  ·  view source on GitHub ↗
(n: i32)

Source from the content-addressed store, hash-verified

16 }
17
18 pub fn fib_dp(n: i32) -> i32 {
19 let mut dp = vec![0; 31];
20 dp[1] = 1;
21 for i in 2..=30 {
22 dp[i] = dp[i-1] + dp[i-2];
23 }
24 dp[n as usize]
25 }
26}
27
28fn main() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected