Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/qiyuangong/leetcode
/ fib
Method
fib
java/509_Fibonacci_Number.java:17–24 ·
view source on GitHub ↗
(int N)
Source
from the content-addressed store, hash-verified
15
}
16
17
public
int
fib(
int
N) {
18
// Dp with memo, O(n)
19
if
(N < memo.size())
return
memo.get(N);
20
for
(
int
i = memo.size(); i <= N; i++) {
21
memo.add(memo.get(i - 1) + memo.get(i - 2));
22
}
23
return
memo.get(N);
24
}
25
}
Callers
nothing calls this directly
Calls
2
get
Method · 0.45
add
Method · 0.45
Tested by
no test coverage detected