We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9ccd8df commit 8e100bfCopy full SHA for 8e100bf
Fibonacci Number - Leetcode 509/Fibonacci Number - Leetcode 509.java
@@ -8,9 +8,10 @@ public int fib(int n) {
8
return fib(n - 1) + fib(n - 2);
9
}
10
11
-
+ // Naive Recursive Solution
12
// Time: O(2^n)
13
// Space: O(n)
14
+
15
16
17
@@ -36,6 +37,7 @@ public int fib(int n) {
36
37
return result;
38
39
40
+ // Top Down DP With Memoization
41
// Time: O(n)
42
43
@@ -59,7 +61,7 @@ public int fib(int n) {
59
61
60
62
return dp[n];
63
64
+ // Bottom Up DP With Tabulation
65
66
67
@@ -84,7 +86,7 @@ public int fib(int n) {
84
86
85
87
return cur;
88
89
+ // Bottom Up DP With Constant Space
90
91
// Space: O(1)
92
0 commit comments