fix(curriculum): clarify DP function calls vs unique subproblems (#65749)

This commit is contained in:
Jeevankumar S
2026-03-03 03:50:28 +05:30
committed by GitHub
parent 4fa56fb02b
commit e0ca86a020

View File

@@ -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)