Topic
Backtracking interview questions
All 12 Backtracking problems from the curated set, easiest first.
- Easy
- 0
- Medium
- 9
- Hard
- 3
- Sheets
- 3
What Backtracking is
Updated 2026-09-09Backtracking is an organized trial-and-error search through a maze of possibilities. You make a tentative choice, move forward to explore where that path leads, and if you hit a dead end or finish finding an answer, you back up and undo that choice. By cleaning up your changes before trying the next option, a single shared board or list is explored thoroughly without needing to clone full copies of your data at every turn.
When to reach for it
Reach for backtracking when a problem asks to generate all possible solutions, like all subsets, permutations, valid parentheses combinations, or word search paths on a board. Signals include puzzles with strict constraint rules, like placing eight non-attacking queens on a chessboard or solving a Sudoku grid. Whenever you must construct combinations step by step and abandon dead-end branches early before wasting time exploring impossible paths, use backtracking.
How to think about it
Follow a three-step rhythm inside a loop: choose, explore, and unchoose. First, check if the current state satisfies your goal; if so, save a copy of it and return. Next, prune illegal moves immediately using constraint checks so unpromising branches are skipped. For each valid candidate, apply the move to your shared path or board, call the recursive function to explore deeper, and finally undo the move right after the call returns. Undoing restores the shared state so sibling choices start from a clean slate.
What each operation costs
| Operation | Time |
|---|---|
| generate all subsets of n elements | O(2^n) |
| generate all permutations of n elements | O(n!) |
| auxiliary recursion stack memory depth | O(n) |
What usually goes wrong
- Adding a mutable path list directly to the final answers collection without creating a shallow copy, leaving every saved result empty once backtracking finishes.
- Forgetting to undo a state change after the recursive call returns, contaminating subsequent branches with leftover moves from earlier paths.
- Generating duplicate subsets or permutations by failing to sort the input array and skip adjacent identical elements during branch selection.
Every Backtracking problem, easiest first
Track Backtracking in your role's order
Pick your target role and all 370 problems resequence to what that interview actually asks. Free.
Start freeBacktracking interview questions, answered
How many Backtracking problems should I solve for interviews?
12 curated Backtracking problems cover the patterns interviews repeat: 0 easy, 9 medium and 3 hard. They are drawn from 3 widely used sheets, deduplicated, and ordered easiest first.
Is Backtracking actually asked in coding interviews?
Backtracking is a supporting topic rather than a core one for most of the 29 roles tracked here, so it is usually worth studying after the topics your target role leans on.
Which Backtracking problem should I start with?
Start with Subsets (Medium). The list on this page is ordered easiest first for that reason, so working top to bottom builds the pattern before the harder variations arrive.
Other topics
Problem set and role mapping as of .