Memoization is an optimization technique used to speed up recursive algorithms by storing the results of expensive function calls and reusing them when the same inputs occur again. Instead of recomputing overlapping subproblems, memoization caches the answer and returns it instantly when needed. This approach is a core concept behind many Dynamic Programming solutions.
Memoization is most commonly applied to problems that naturally use Recursion. When a recursive function repeatedly solves the same subproblem, storing results in a cache—often implemented with a Hash Table or array—can dramatically reduce time complexity.
In coding interviews, memoization helps transform inefficient exponential solutions into efficient polynomial-time algorithms. You'll frequently see it used in problems involving sequences, paths, or decision trees.
Mastering memoization allows you to quickly recognize overlapping subproblems and implement efficient solutions during interviews. Practicing these problems will also strengthen your intuition for transitioning from recursion to dynamic programming.
Arrays are often used as memo tables when problem states can be indexed numerically.
Memoization is typically applied to recursive solutions to avoid recomputing overlapping subproblems.
Hash tables are commonly used to store cached results for previously computed inputs.
Memoization represents the top-down approach to dynamic programming and helps understand optimal substructure.
| Status | Title | Video | Leetcode | Solve | Difficulty | Companies | Topics |
|---|---|---|---|---|---|---|---|
| 139. Word Break | Solve | Medium | Accenture+38 | ||||
| 241. Different Ways to Add Parentheses | Solve | Medium | Bloomberg+2 | ||||
| 294. Flip Game II | Solve | Medium | Google | ||||
| 397. Integer Replacement | Solve | Medium | Bloomberg | ||||
| 464. Can I Win | Solve | Medium | LinkedIn | ||||
| 638. Shopping Offers | Solve | Medium | Amazon+3 | ||||
| 698. Partition to K Equal Sum Subsets | Solve | Medium | Amazon+2 | ||||
| 894. All Possible Full Binary Trees | Solve | Medium | Adobe+6 | ||||
| 1387. Sort Integers by The Power Value | Solve | Medium | Bloomberg+1 | ||||
| 2311. Longest Binary Subsequence Less Than or Equal to K | Solve | Medium | Amazon+1 | ||||
| 2998. Minimum Number of Operations to Make X and Y Equal | Solve | Medium | - | ||||
| 3040. Maximum Number of Operations With the Same Score II | Solve | Medium | - |
Start Easy, progress to Hard.
Frequently appear alongside Memoization.
Common questions about Memoization.
Memoization commonly uses arrays or hash tables to store previously computed results. The choice depends on how the problem state is represented and indexed.
Memoization is a form of dynamic programming that uses a top-down approach with recursion and caching. Dynamic programming can also be implemented bottom-up using tabulation.
Use memoization when a recursive solution repeatedly solves the same subproblems. If you notice overlapping computations in recursion trees, caching results can reduce time complexity dramatically.
Memoization is a technique where the results of function calls are stored and reused when the same inputs appear again. It prevents repeated computation and significantly improves the performance of recursive algorithms.
Practicing around 30–40 memoization problems is usually enough to build strong intuition. Focus on recognizing overlapping subproblems and implementing efficient caching strategies.