-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit 8bf29fe
authored
merge: Optimize the space complexity of the fibonacci algo (#899)
* docs: update js doc
* feat: add number type validation condition
* pref: Optimize space complexity
remove the Array from the algo and used two flag varible to calculate last two numbers & optimize the sapce complexity O(n) to O(1)
* test: add test case for invalid types1 parent 743b317 commit 8bf29fe
File tree
2 files changed
+23
-9
lines changed- Dynamic-Programming
- tests
2 files changed
+23
-9
lines changedLines changed: 16 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | - | ||
2 | + | ||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 | - | ||
10 | - | ||
11 | - | ||
12 | - | ||
13 | - | ||
14 | - | ||
9 | + | ||
10 | + | ||
15 | 11 |
| |
16 | - | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | + | ||
24 | + | ||
17 | 25 |
| |
18 | 26 |
| |
19 | 27 |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | - | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + | ||
4 | 10 |
| |
5 | 11 |
| |
6 | 12 |
| |
|
0 commit comments