DDSA Solutions

Memoization

5 problems · 5 with full explanations

1 Easy2 Medium2 Hard
Memoization caches the return value of a function for each unique input, converting exponential recursion to polynomial time. Use a Dictionary<(int, int), int> or a 2D array. Identify the "state" (all parameters that uniquely determine the result) to design the cache key.

How to practice

To practice Memoization problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the memoization pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Memoization problems