CONTENTS

Recursion and Backtracking Roadmap

Understand recursion, pick/skip decisions, valid-state generation, and grid backtracking for coding interviews.

May 29, 2026
45
A

Backtracking is recursion with undo. The goal is not to try everything blindly; the goal is to try only states that can still become valid.

Backtracking Templates

TemplateUse It ForPractice
Pick or skipSubsets and subsequencesSubsets
Valid state growthParentheses and constraintsGenerate Parentheses
Reuse choiceCombination sumCombination Sum
Grid pathBoard searchWord Search

Backtracking Diagram

choose -> recurse -> undo
stop when valid answer or invalid state

FAQs

What is the difference between recursion and backtracking?

Recursion is the call structure. Backtracking adds choice, constraint checking, and undoing state.

Why do I need to copy the path?

The path list keeps changing. Store a copy when you record an answer.

Share this article

0 comments

Please login to comment.
No comments yet.