mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-07 09:01:13 -05:00
fix(curriculum): clarify DP function calls vs unique subproblems (#65749)
This commit is contained in:
@@ -46,7 +46,7 @@ This implementation has exponential time complexity because of massive redundant
|
||||
- `climb_stairs(2)` gets calculated **3 times total**
|
||||
|
||||
|
||||
For just `n=5`, we make 9 function calls when we only need 5 unique calculations. As `n` grows, this redundancy explodes exponentially - `climb_stairs(30)` would require over 1 billion function calls! The time complexity becomes `O(2^n)`, making it inefficient and impractical for larger values of `n`.
|
||||
For just `n=5`, we make 9 function calls when we only need 5 unique calculations. As `n` grows, this redundancy explodes exponentially - `climb_stairs(30)` would require a few million function calls. The time complexity becomes `O(2^n)`, making it inefficient and impractical for larger values of `n`.
|
||||
|
||||
## Dynamic Programming Solutions
|
||||
|
||||
@@ -113,7 +113,7 @@ Call: climb_stairs_memo(5)
|
||||
|
||||
- **Space complexity**: `O(n)` for the memo storage and call stack
|
||||
|
||||
- **Real impact**: `climb_stairs(30)` drops from 1+ billion calls to just 30 calls!
|
||||
- **Real impact**: `climb_stairs(30)` drops from millions of function calls to about 30 unique subproblem calculations
|
||||
|
||||
|
||||
### Tabulation (Bottom-Up Approach)
|
||||
|
||||
Reference in New Issue
Block a user