Memoization interview questions
Practice 8 questions on memoization. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
8 questions
- EASY
Once
Implement a function that wraps a callback so it runs at most one time and reuses that result thereafter.
15 minJavaScript - EASY
useCounter II
Rewrite useCounter so the returned helpers keep stable identities across renders.
15 minJavaScript - MEDIUM
Distinct Paths in Grid
Implement a function that counts the number of unique paths a robot can take from the top-left to bottom-right of an m by n grid.
25 minAlgorithms - MEDIUM
Memoize
Implement a function that caches results of a single-argument function so repeat calls return instantly.
25 minJavaScript - MEDIUM
Memoize II
PREMIUMImplement a memoize helper that caches results for functions called with any number and type of arguments.
25 minJavaScript - MEDIUM
Memoize III
PREMIUMExtend memoize with a custom key resolver and cache controls (.clear() and .delete(key)).
25 minJavaScript - MEDIUM
Reselect Selectors
PREMIUMBuild memoized selectors that recompute only when their input selections change by reference.
25 minJavaScript - MEDIUM
Segment Words
Implement a function that decides whether a string can be broken into a sequence of words from a given dictionary.
25 minAlgorithmsAmazon · Google · Meta