Memoization LeetCode Problems: All 39, With Python Solutions

Every problem in this library that LeetCode tags Memoization 39 in total, 38 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 39 problems
  • 3 Easy
  • 11 Medium
  • 25 Hard

How Memoization problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Memoization problems — each one explains the approach, gives a Python template and states its complexity.

  • Dynamic Programming — Define a state, write the transition, and stop recomputing the same subproblem.

Memoization problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (3)

#ProblemDifficultyTopics
70Climbing StairsEasyMemoization, Math, Dynamic Programming
509Fibonacci NumberEasyRecursion, Memoization, Math +1
1137N-th Tribonacci NumberEasyMemoization, Math, Dynamic Programming

Medium (11)

#ProblemDifficultyTopics
139Word BreakMediumTrie, Memoization, Array +3
241Different Ways to Add ParenthesesMediumRecursion, Memoization, Math +2
397Integer ReplacementMediumGreedy, Bit Manipulation, Memoization +1
464Can I WinMediumBit Manipulation, Memoization, Math +3
638Shopping OffersMediumBit Manipulation, Memoization, Array +3
698Partition to K Equal Sum SubsetsMediumBit Manipulation, Memoization, Array +3
894All Possible Full Binary TreesMediumTree, Recursion, Memoization +2
1387Sort Integers by The Power ValueMediumMemoization, Dynamic Programming, Sorting
2311Longest Binary Subsequence Less Than or Equal to KMediumGreedy, Memoization, String +1
2998Minimum Number of Operations to Make X and Y EqualMediumBreadth-First Search, Memoization, Dynamic Programming
294Flip Game IIPremiumMediumMemoization, Math, Dynamic Programming +2

Hard (25)

#ProblemDifficultyTopics
140Word Break IIHardTrie, Memoization, Array +4
329Longest Increasing Path in a MatrixHardDepth-First Search, Breadth-First Search, Graph +5
488Zuma GameHardStack, Breadth-First Search, Memoization +2
546Remove BoxesHardMemoization, Array, Dynamic Programming
691Stickers to Spell WordHardBit Manipulation, Memoization, Array +5
773Sliding PuzzleHardBreadth-First Search, Memoization, Array +3
913Cat and MouseHardGraph, Topological Sort, Memoization +3
964Least Operators to Express NumberHardMemoization, Math, Dynamic Programming
1444Number of Ways of Cutting a PizzaHardMemoization, Array, Dynamic Programming +2
1553Minimum Number of Days to Eat N OrangesHardMemoization, Dynamic Programming
1569Number of Ways to Reorder Array to Get Same BSTHardTree, Union Find, Binary Search Tree +7
1575Count All Possible RoutesHardMemoization, Array, Dynamic Programming
1611Minimum One Bit Operations to Make Integers ZeroHardBit Manipulation, Memoization, Dynamic Programming
1659Maximize Grid HappinessHardBit Manipulation, Memoization, Dynamic Programming +1
1728Cat and Mouse IIHardGraph, Topological Sort, Memoization +5
1815Maximum Number of Groups Getting Fresh DonutsHardBit Manipulation, Memoization, Array +2
1857Largest Color Value in a Directed GraphHardGraph, Topological Sort, Memoization +3
1900The Earliest and Latest Rounds Where Players CompeteHardMemoization, Dynamic Programming
2019The Score of Students Solving Math ExpressionHardStack, Memoization, Array +4
2312Selling Pieces of WoodHardMemoization, Array, Dynamic Programming
2318Number of Distinct Roll SequencesHardMemoization, Dynamic Programming
2328Number of Increasing Paths in a GridHardDepth-First Search, Breadth-First Search, Graph +5
2713Maximum Strictly Increasing Cells in a MatrixHardMemoization, Array, Hash Table +5
2876Count Visited Nodes in a Directed GraphHardGraph, Memoization, Dynamic Programming
2920Maximum Points After Collecting Coins From All NodesHardBit Manipulation, Tree, Depth-First Search +3

When the Memoization problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.