Recursion LeetCode Problems: All 45, With Python Solutions

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

  • 45 problems
  • 9 Easy
  • 22 Medium
  • 14 Hard

Recursion problems by difficulty

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

Easy (9)

#ProblemDifficultyTopics
21Merge Two Sorted ListsEasyRecursion, Linked List
203Remove Linked List ElementsEasyRecursion, Linked List
206Reverse Linked ListEasyRecursion, Linked List
231Power of TwoEasyBit Manipulation, Recursion, Math
234Palindrome Linked ListEasyStack, Recursion, Linked List +1
326Power of ThreeEasyRecursion, Math
342Power of FourEasyBit Manipulation, Recursion, Math
509Fibonacci NumberEasyRecursion, Memoization, Math +1
2094Finding 3-Digit Even NumbersEasyRecursion, Array, Hash Table +2

Medium (22)

#ProblemDifficultyTopics
2Add Two NumbersMediumRecursion, Linked List, Math
24Swap Nodes in PairsMediumRecursion, Linked List
50Pow(x, n)MediumRecursion, Math
143Reorder ListMediumStack, Recursion, Linked List +1
241Different Ways to Add ParenthesesMediumRecursion, Memoization, Math +2
390Elimination GameMediumRecursion, Math
394Decode StringMediumStack, Recursion, String
486Predict the WinnerMediumRecursion, Array, Math +2
779K-th Symbol in GrammarMediumBit Manipulation, Recursion, Math
894All Possible Full Binary TreesMediumTree, Recursion, Memoization +2
1545Find Kth Bit in Nth Binary StringMediumRecursion, String, Simulation
1823Find the Winner of the Circular GameMediumRecursion, Queue, Array +2
1922Count Good NumbersMediumRecursion, Math
1969Minimum Non-Zero Product of the Array ElementsMediumGreedy, Recursion, Math
2487Remove Nodes From Linked ListMediumStack, Recursion, Linked List +1
2550Count Collisions of Monkeys on a PolygonMediumRecursion, Math
247Strobogrammatic Number IIPremiumMediumRecursion, Array, String
255Verify Preorder Sequence in Binary Search TreePremiumMediumStack, Tree, Binary Search Tree +4
439Ternary Expression ParserPremiumMediumStack, Recursion, String
544Output Contest MatchesPremiumMediumRecursion, String, Simulation
776Split BSTPremiumMediumTree, Binary Search Tree, Recursion +1
1265Print Immutable Linked List in ReversePremiumMediumStack, Recursion, Linked List +1

Hard (14)

#ProblemDifficultyTopics
10Regular Expression MatchingHardRecursion, String, Dynamic Programming
25Reverse Nodes in k-GroupHardRecursion, Linked List
44Wildcard MatchingHardGreedy, Recursion, String +1
60Permutation SequenceHardRecursion, Math
224Basic CalculatorHardStack, Recursion, Math +1
233Number of Digit OneHardRecursion, Math, Dynamic Programming
273Integer to English WordsHardRecursion, Math, String
736Parse Lisp ExpressionHardStack, Recursion, Hash Table +1
761Special Binary StringHardRecursion, String
1106Parsing A Boolean ExpressionHardStack, Recursion, String
1808Maximize Number of Nice DivisorsHardRecursion, Math, Number Theory
248Strobogrammatic Number IIIPremiumHardRecursion, Array, String
770Basic Calculator IVHardStack, Recursion, Hash Table +2
772Basic Calculator IIIPremiumHardStack, Recursion, Math +1

When the Recursion 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.