Memoization
Memoization is an optimization technique that caches the results of expensive function calls so that when the same inputs occur again, the cached result is returned instead of recomputing it.
23 resources across 3 libraries
Glossary Terms(3)
Hash Table
A hash table (or hash map) is a data structure that maps keys to values using a hash function to compute an index into an array of buckets, giving average O(1)…
Dynamic Programming
Dynamic programming (DP) is an algorithmic technique for solving problems by breaking them into overlapping subproblems, solving each subproblem once, and stor…
Memoization
Memoization is an optimization technique that caches the results of expensive function calls so that when the same inputs occur again, the cached result is ret…
Study Notes(1)
Interview Questions(19)
What is Dynamic Programming?
Dynamic programming is a technique for solving problems by breaking them into overlapping subproblems and storing each subproblem’s result so it is computed on…
What is the Difference Between Time and Space Complexity?
Time complexity measures how the number of operations an algorithm performs grows with input size, while space complexity measures how the memory it needs grow…
What is Memoization?
Memoization is an optimization technique that caches the results of expensive function calls keyed by their arguments, so repeated calls with the same inputs r…
Greedy vs Dynamic Programming: What is the Difference?
Greedy algorithms make the locally optimal choice at each step and never reconsider it, while dynamic programming explores overlapping subproblems and combines…
0/1 Knapsack Problem: How Would You Solve It?
The 0/1 knapsack problem is solved with dynamic programming: build a table dp[i][w] representing the best value achievable using the first i items within capac…
Unbounded Knapsack Problem: How Is It Different?
The unbounded knapsack problem allows each item type to be picked an unlimited number of times, so the DP recurrence becomes dp[w] = max(dp[w], value[i] + dp[w…
Coin Change Problem: How Would You Solve It?
The coin change problem (minimum coins to make an amount) is solved with dynamic programming: dp[a] holds the fewest coins needed to make amount a, computed as…
How Does Matrix Chain Multiplication Work?
Matrix chain multiplication finds the cheapest order to parenthesize a chain of matrix multiplications — not the product itself — using dynamic programming in…
What is the Rod Cutting Problem?
The rod cutting problem asks for the maximum revenue obtainable by cutting a rod of length n into pieces and selling each piece at a given price, and it is sol…
How Do You Solve Fibonacci with Dynamic Programming?
Naive recursive Fibonacci recomputes the same subproblems exponentially many times, costing O(2^n) time, so dynamic programming fixes this by storing each F(i)…
Climbing Stairs Problem: How Do You Solve It?
The climbing stairs problem is solved with dynamic programming by recognizing that the number of ways to reach step n equals the sum of the ways to reach step…
Word Break Problem: How Do You Solve It?
The word break problem — deciding whether a string can be segmented into a sequence of words from a given dictionary — is solved with dynamic programming where…
What is the Minimum Path Sum Problem?
The minimum path sum problem asks for the smallest total cost of a path from the top-left to the bottom-right of a grid, moving only right or down, and it is s…
Top-Down vs Bottom-Up Dynamic Programming: What is the Difference?
Top-down dynamic programming solves a problem by recursing from the original goal toward base cases, caching each subproblem result the first time it is comput…
Tabulation vs Memoization: How Do They Differ in Dynamic Programming?
Memoization is the technique of caching results of a recursive function call so repeated calls with the same arguments return instantly, while tabulation is th…
What is Digit Dynamic Programming (Digit DP)?
Digit DP is a dynamic programming technique for counting or summarizing numbers within a range (like 1 to N) that satisfy a digit-based property — such as “dig…
What Is a Closure in JavaScript?
A closure is a function bundled together with references to the variables from its enclosing lexical scope, so the function keeps access to those variables eve…
What Is Memoization in JavaScript?
Memoization is an optimization technique that caches the return value of an expensive, pure function keyed by its input arguments, so that calling the function…
useMemo vs useCallback: What Is the Difference?
useMemo memoizes the returned value of an expensive computation so it is only recalculated when its dependencies change, while useCallback memoizes the functio…