Algorithms

Memoization

Storing each subproblem's result the first time it is computed, so it is read later instead of computed again.

Example

Climbing 40 stairs 1 or 2 at a time without storing anything makes hundreds of millions of calls; storing each dp[i], it takes 40.

Test yourself: Memoization

Dynamic programming

Storing each result in mem, the time goes from O(2ⁿ) to O(___).

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.