Recursion & Backtracking Interview Questions
Backtracking questions — permutations, combinations, subsets, N-queens — test whether you can enumerate a search space and prune it without losing correctness.
Backtracking is systematic search: build a candidate solution one choice at a time, abandon a branch as soon as it cannot lead to a valid answer, and undo the last choice before trying the next. Permutations, combinations, subsets, and constraint puzzles such as N-queens are all the same skeleton with a different validity check.
What interviewers probe
The template is what to demonstrate — choose, recurse, un-choose — because getting the undo step wrong produces answers that are subtly polluted by earlier branches. Interviewers also expect an honest complexity statement: these solutions are frequently exponential and that is acceptable, but saying so unprompted shows you understand the cost. Where pruning is possible, naming the pruning condition is the difference between a brute force and a designed search.
Practice recursion & backtracking
7 coding · 4/2/1 easy/medium/hard
Recursion & Backtracking interview questions — FAQ
What is the standard backtracking template?
Make a choice, recurse on the smaller problem, then undo the choice before the next iteration. Nearly every permutation, combination and subset question is that skeleton with a different constraint check.
Is exponential complexity acceptable in an interview?
Often yes, when the problem genuinely requires enumerating a search space. What is not acceptable is failing to notice — state the complexity, then discuss what pruning or memoisation could reduce it.