Backtracking interview questions
Practice 7 questions on backtracking. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
7 questions
- MEDIUM
Combinations for Target Sum
Implement a function that returns every unique combination of reusable candidates that sums to a target.
25 minAlgorithms - MEDIUM
Generate Parentheses
Generate every well-formed combination of n pairs of parentheses by backtracking — add an open bracket while any remain, and a close bracket only while it stays balanced.
25 minAlgorithms - MEDIUM
Palindrome Partitioning
Split a string every possible way so that each piece is a palindrome — backtrack over cut positions, extending a piece only while it reads the same both ways.
25 minAlgorithms - MEDIUM
Permutations & Subsets
PREMIUMGenerate every permutation and every subset of an array with the same backtracking template — choose, recurse, and undo.
25 minAlgorithms - MEDIUM
Phone Letter Combinations
List every letter string a phone number could spell, mapping each digit to its keypad letters and backtracking through the choices.
25 minAlgorithms - HARD
N-Queens
PREMIUMPlace N queens on an N×N board so none attack another — a classic backtracking search that places one queen per row and prunes column and diagonal conflicts.
40 minAlgorithms - HARD
Sudoku Solver
PREMIUMFill a 9×9 Sudoku grid by backtracking — try each digit in the next empty cell, checking its row, column, and 3×3 box, and undo on a dead end.
40 minAlgorithms