pyPython Practice LabFrom first print to final round
TOPIC 08 OF 18

Recursion and Backtracking Python practice problems

Understand base cases, shrinking subproblems, recursive search, and choice-and-undo backtracking.

20 exercises8+ conceptsBeginner → interview context
Start this topic
WHAT YOU WILL PRACTISE

Core concepts

Compute factorial recursivelySum digits recursivelyCalculate integer power recursivelyFind GCD recursivelyBinary search recursivelyCheck a palindrome recursivelyGenerate all permutationsGenerate all subsets
REUSABLE THINKING

Problem-solving patterns

  • Base case → make a smaller choice → recurse → undo if needed
INTERVIEW SIGNALS

Reported company tags

AmazonGoogleMicrosoftMetaBloomberg
Community-reported tags are guidance, not guarantees.
ORDERED PRACTICE

All 20 problems in this topic

Work from top to bottom to build the concept gradually.

  1. #141
    Compute factorial recursively: Recursive arrangement count

    Use recursion to calculate seven factorial.

    IntermediatePremium
  2. #142
    Compute factorial recursively: Recursive base case

    Verify that the base case returns one for zero.

    IntermediatePremium
  3. #143
    Sum digits recursively: Checksum

    Calculate a simple digit checksum recursively.

    IntermediatePremium
  4. #144
    Sum digits recursively: Negative input

    Ignore the sign before summing a negative number's digits.

    IntermediatePremium
  5. #145
    Calculate integer power recursively: Large exponent efficiently

    Compute a power using logarithmic recursion.

    IntermediatePremium
  6. #146
    Calculate integer power recursively: Zero exponent

    Any nonzero base raised to zero returns one.

    IntermediatePremium
  7. #147
    Find GCD recursively: Shared factor

    Find the greatest common divisor of two related values.

    IntermediatePremium
  8. #148
    Find GCD recursively: Second input zero

    The base case returns the first value immediately.

    IntermediatePremium
  9. #149
    Binary search recursively: Found target

    Find the zero-based index of a target in a sorted catalog.

    IntermediatePremium
  10. #150
    Binary search recursively: Missing target

    Return -1 after the search range becomes empty.

    IntermediatePremium
  11. #151
    Check a palindrome recursively: Odd-length palindrome

    Verify a word with one middle character.

    IntermediatePremium
  12. #152
    Check a palindrome recursively: Early mismatch

    Stop and return False as soon as outer characters differ.

    IntermediatePremium
  13. #153
    Generate all permutations: Three-character arrangements

    List every ordering of three distinct task labels.

    IntermediatePremium
  14. #154
    Generate all permutations: Two-character arrangements

    Show the smallest nontrivial permutation set.

    IntermediatePremium
  15. #155
    Generate all subsets: Feature subsets

    List every subset of three numbered features.

    IntermediatePremium
  16. #156
    Generate all subsets: Single value

    A one-value set has the empty subset and one nonempty subset.

    IntermediatePremium
  17. #157
    Generate balanced parentheses: Three pairs

    Generate every valid expression containing three pairs.

    IntermediatePremium
  18. #158
    Generate balanced parentheses: One pair

    Generate the single valid expression for one pair.

    IntermediatePremium
  19. #159
    Count N-Queens solutions: Classic four-queen board

    Count valid arrangements on a 4-by-4 chessboard.

    IntermediatePremium
  20. #160
    Count N-Queens solutions: Five-queen board

    Count solutions for the next board size to exercise more branches.

    IntermediatePremium