Skip to content

Commit 8e100bf

Browse files
authored
Update Fibonacci Number - Leetcode 509.java
1 parent 9ccd8df commit 8e100bf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Fibonacci Number - Leetcode 509/Fibonacci Number - Leetcode 509.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ public int fib(int n) {
88
return fib(n - 1) + fib(n - 2);
99
}
1010
}
11-
11+
// Naive Recursive Solution
1212
// Time: O(2^n)
1313
// Space: O(n)
14+
1415
}
1516

1617

@@ -36,6 +37,7 @@ public int fib(int n) {
3637
return result;
3738
}
3839

40+
// Top Down DP With Memoization
3941
// Time: O(n)
4042
// Space: O(n)
4143
}
@@ -59,7 +61,7 @@ public int fib(int n) {
5961

6062
return dp[n];
6163
}
62-
64+
// Bottom Up DP With Tabulation
6365
// Time: O(n)
6466
// Space: O(n)
6567
}
@@ -84,7 +86,7 @@ public int fib(int n) {
8486

8587
return cur;
8688
}
87-
89+
// Bottom Up DP With Constant Space
8890
// Time: O(n)
8991
// Space: O(1)
9092
}

0 commit comments

Comments
 (0)