HomeRecursion
Recursion
Choose, recurse, un-choose — patterns that build every path.
30 shown
- OverviewBase case, recursive case, the call stackanimatedEasy
- Fast Exponentiationxⁿ via repeated squaring · O(log n)animatedMedium
- Print All SubsequencesTake / don't take at each indexanimatedMedium
- Subset SumExplore include/exclude, prune on targetanimatedMedium
- Practice problems
- Understand recursion by print something N timesA base case and one smaller callEasy
- Print name N times using recursionThe same shape, with a payloadEasy
- Print 1 to N using RecursionRecurse first, print on the way backEasy
- Print N to 1 using RecursionPrint first, then recurseEasy
- Sum of First N Numbersn plus the sum of everything belowEasy
- Factorial of a given numbern times the factorial below itEasy
- Reverse an arraySwap the ends, recurse inwardEasy
- Check if String is Palindrome or NotEnds match, then check the middleEasy
- Fibonacci NumberTwo branches, and why they explodeanimatedEasy
- Recursive Implementation of atoi()Build the number from the frontMedium
- Pow(x, n)Square the half poweranimatedEasy
- Count Good NumbersIndependent choices, multipliedMedium
- Sort a stack using recursionPop everything, insert on the way backMedium
- Reverse a StackInsert each element at the bottomMedium
- Generate Binary Strings Without Consecutive 1sTrack only the previous characterMedium
- Generate ParenthesesOpen while you can, close while it stays validMedium
- Power SetTake it or leave it, at every elementanimatedMedium
- Learn All Patterns of Subsequences (Theory)The take / not-take skeletonanimatedEasy
- Count all subsequences with sum KTake / not-take, returning countsanimatedEasy
- Check if there exists a subsequence with sum KThe same branch, returning a booleananimatedEasy
- Combination SumReuse allowed, so stay on the same indexMedium
- Combination Sum IIEach element once, duplicates skipped at each levelMedium
- Subsets ITake or skip, collect the leavesanimatedMedium
- Subsets IISort, then skip duplicates at each levelMedium
- Combination Sum IIIk numbers from 1..9, each onceMedium
- Letter Combinations of a Phone NumberOne digit per level, a branch per letterHard