Recursion

24 articles

dsa8 min read

Reverse Nodes in k-Group — Recursive and Iterative Deep Dive

Master reversing nodes in groups of k in a linked list — the classic hard interview problem asked at Amazon, Google, Facebook, and Microsoft. Learn both the elegant recursive solution and the iterative approach with clear pointer diagrams.

Read →
dsa14 min read

Combination Sum [Medium] — Backtracking with Pruning (LC 39)

Master LeetCode 39 — Combination Sum by understanding the backtracking decision tree, why unlimited reuse is handled by staying at the same index, and how sorting enables early pruning. Includes Python and JavaScript solutions with line-by-line comments, a full visual dry run, common mistakes, and follow-up questions on LC 40, LC 216, and LC 377.

Read →
dsa9 min read

Sudoku Solver — Constraint Propagation Plus Backtracking

LC 37 Sudoku Solver is the most-asked constraint-satisfaction problem in tech interviews. Master row, column, and box bitsets, MRV heuristic ordering, and the cell-by-cell decision tree that solves any 9x9 grid in milliseconds.

Read →
dsa5 min read

Delete Node in a BST — LC 450 Interview Deep Dive

LC 450 Delete Node in a BST is a top FAANG interview problem testing all three deletion cases. Master the in-order successor strategy to pass BST questions at Amazon, Google, and Microsoft.

Read →
dsa6 min read

Construct Quad Tree — LC 427 Divide and Conquer Grid

LC 427 Construct Quad Tree builds a spatial partitioning tree from a 2D binary grid by recursively splitting non-uniform regions into four quadrants. This divide-and-conquer problem is tested at Amazon and Google and models real-world image compression and spatial indexing.

Read →