backtracking
backtracking is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
High-Pressure Round
Letter Combinations of a Phone Number
Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…
Generate Parentheses
Generate Parentheses requires generating all valid combinations of parentheses with given pairs using backtracking and s…
Sudoku Solver
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
Combination Sum
Find all unique combinations of numbers from a distinct array that sum to a target using controlled backtracking search.
Combination Sum II
Find all unique combinations of numbers that sum to a target using backtracking with careful pruning to avoid duplicates…
Permutations
Generate all possible orderings of a distinct integer array using backtracking search with careful pruning to avoid dupl…
Permutations II
Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…
N-Queens
Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…
N-Queens II
Solve the N-Queens II problem using backtracking with pruning to efficiently count all valid placements for n queens on …
Combinations
Generate all combinations of k numbers from the range [1, n] using backtracking and pruning.
Subsets
Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.
Word Search
Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.
Gray Code
Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.
Subsets II
Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…
Restore IP Addresses
Restore all valid IP addresses from a string using backtracking with pruning, avoiding invalid segments or leading zeros…
Unique Binary Search Trees II
Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.
Path Sum II
Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.
Word Ladder II
Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …
Palindrome Partitioning
Find all possible palindrome partitioning of a string using backtracking and dynamic programming.
Word Break II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
Word Search II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
Combination Sum III
Find all unique combinations of k numbers adding to n using efficient backtracking with pruning in arrays.
Binary Tree Paths
Find all root-to-leaf paths in a binary tree using DFS and backtracking, constructing strings for each complete path eff…
Expression Add Operators
Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…
Remove Invalid Parentheses
Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…
Additive Number
Additive Number is solved by trying the first two splits, then pruning aggressively while verifying each required sum in…
Count Numbers with Unique Digits
The problem asks to count numbers with unique digits from 0 to 10^n using dynamic programming, math, and backtracking te…
Binary Watch
Binary Watch involves generating possible times on a binary watch given a number of turned-on LEDs.
Matchsticks to Square
The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…
Non-decreasing Subsequences
Return all possible non-decreasing subsequences with at least two elements from the input array, nums.
Target Sum
Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…
Beautiful Arrangement
The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…
Shopping Offers
Minimize the cost of purchasing items using available special offers with state transition dynamic programming.
24 Game
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
Stickers to Spell Word
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
Partition to K Equal Sum Subsets
Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…
Sliding Puzzle
Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …
Letter Case Permutation
Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.
All Paths From Source to Target
Find all paths in a directed acyclic graph (DAG) from source to target using depth-first search and backtracking.
Ambiguous Coordinates
Find all valid 2D coordinate possibilities for an ambiguous input string using backtracking and pruning techniques.
Split Array into Fibonacci Sequence
This problem challenges you to split a string into a Fibonacci-like sequence using backtracking and pruning.
Largest Time for Given Digits
Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.
Numbers With Same Consecutive Differences
Generate all n-digit numbers where consecutive digits differ by k using efficient backtracking and BFS techniques.
Unique Paths III
Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…
Smallest String Starting From Leaf
Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…
Number of Squareful Arrays
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
Letter Tile Possibilities
Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.
Brace Expansion II
Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…
Path with Maximum Gold
Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.
Circular Permutation in Binary Representation
Generate a circular permutation from a range of numbers using backtracking and bit manipulation.
Maximum Length of a Concatenated String with Unique Characters
Find the maximum length of a concatenated string from an array with all unique characters using backtracking search with…
Tiling a Rectangle with the Fewest Squares
Tiling a Rectangle with the Fewest Squares problem asks for the minimum number of squares required to cover a rectangle …
Maximum Score Words Formed by Letters
Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…
Iterator for Combination
Implement an iterator that generates all combinations of a given length using efficient backtracking with pruning.
Verbal Arithmetic Puzzle
Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.
The k-th Lexicographical String of All Happy Strings of Length n
Given n and k, find the k-th lexicographical happy string of length n using backtracking search with pruning.
Probability of a Two Boxes Having The Same Number of Distinct Balls
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
Split a String Into the Max Number of Unique Substrings
Maximize unique substrings in a string using backtracking with pruning and hash tables to track substrings.
Maximum Number of Achievable Transfer Requests
Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.
Distribute Repeating Integers
Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…
Construct the Lexicographically Largest Valid Sequence
Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…
Find Minimum Time to Finish All Jobs
Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…
Closest Dessert Cost
Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…
Maximize Score After N Operations
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
Splitting a String Into Descending Consecutive Values
Check if a string of digits can be split into descending consecutive values where the difference between them is 1.
Sum of All Subset XOR Totals
Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.
Maximum Compatibility Score Sum
Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…
Find Unique Binary String
Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.
Minimum Number of Work Sessions to Finish the Tasks
Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.
Maximum Product of the Length of Two Palindromic Subsequences
Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…
Longest Subsequence Repeated k Times
Find the longest subsequence repeated k times in a string using backtracking search with pruning.
Count Number of Maximum Bitwise-OR Subsets
Determine the number of non-empty subsets that achieve the maximum bitwise OR using efficient backtracking and pruning s…
Next Greater Numerically Balanced Number
Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.
Number of Valid Move Combinations On Chessboard
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
Maximum Path Quality of a Graph
Calculate the maximum path quality in a graph using backtracking and pruning to optimize node visits within time limits …
Maximum Good People Based on Statements
Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.
Maximum Split of Positive Even Integers
Determine the largest set of unique positive even integers that sum to a given finalSum using backtracking and greedy se…
Maximum Points in an Archery Competition
In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…
Fair Distribution of Cookies
The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…
Construct Smallest Number From DI String
Construct the lexicographically smallest string that fits the increasing and decreasing conditions of a given pattern.
Maximum Rows Covered by Columns
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
The Number of Beautiful Subsets
Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…
Find the Punishment Number of an Integer
Find the punishment number of a given integer using backtracking search with pruning.
Maximum Strength of a Group
Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…
Partition String Into Minimum Beautiful Substrings
Partition a binary string into the fewest beautiful substrings using state transition dynamic programming and careful su…
Generate Binary Strings Without Adjacent Zeros
Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…
Smallest Divisible Digit Product II
Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…
Minimum Time to Break Locks I
Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…
Related Patterns
Backtracking search with pruning
52 linked problems
State transition dynamic programming
22 linked problems
Array scanning plus hash lookup
7 linked problems
Binary-tree traversal and state tracking
4 linked problems
Stack-based state management
2 linked problems
Graph traversal with depth-first search
1 linked problems