Skip to main content

Recursion Leetcode Questions

A collection of 20 Leetcode questions focused on recursion, categorized into easy, medium, and hard levels.

Easy​

  1. Factorial
    • Description: Calculate the factorial of a given number using recursion.
  2. Fibonacci Number
    • Description: Compute the n-th Fibonacci number using recursion.
  3. Reverse String
    • Description: Reverse a string using recursion.
  4. Sum of Digits of a Number
    • Description: Find the sum of digits of a given number using recursion.
  5. Power of Three
    • Description: Determine if a number is a power of three using recursion.
  6. Climbing Stairs
    • Description: Find the number of ways to climb a staircase using recursion.
  7. Palindrome Linked List
    • Description: Check if a linked list is a palindrome using recursion.
  8. Maximum Depth of Binary Tree
    • Description: Find the maximum depth of a binary tree using recursion.

Medium​

  1. Subsets
    • Description: Generate all possible subsets of a set using recursion.
  2. Permutations
    • Description: Generate all possible permutations of a sequence using recursion.
  3. Unique Binary Search Trees II
    • Description: Generate all unique BSTs that store values 1 to n using recursion.
  4. Word Search
    • Description: Search for a word in a 2D grid using recursion.
  5. Combination Sum
    • Description: Find all unique combinations of numbers that sum to a target using recursion.
  6. Letter Combinations of a Phone Number
    • Description: Generate all possible letter combinations that a phone number could represent using recursion.
  7. Generate Parentheses
    • Description: Generate all combinations of well-formed parentheses using recursion.

Hard​

  1. N-Queens
    • Description: Solve the N-Queens problem using recursion.
  2. Sudoku Solver
    • Description: Solve a given Sudoku puzzle using recursion.
  3. Regular Expression Matching
    • Description: Implement regular expression matching with support for '.' and '*' using recursion.
  4. Longest Valid Parentheses
    • Description: Find the length of the longest valid parentheses substring using recursion.
  5. Interleaving String
    • Description: Determine if a string is an interleaving of two other strings using recursion.

These questions provide a comprehensive overview of recursion techniques and are a great way to practice and improve your recursion skills in data structures and algorithms.