LeetCodechevron_rightCategorieschevron_rightbacktracking
undo

backtracking

88 problems
Easy: 3Medium: 58Hard: 27

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

#TitleDifficulty
17

Letter Combinations of a Phone Number

Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…

Medium
22

Generate Parentheses

Generate Parentheses requires generating all valid combinations of parentheses with given pairs using backtracking and s…

Medium
37

Sudoku Solver

Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.

Hard
39

Combination Sum

Find all unique combinations of numbers from a distinct array that sum to a target using controlled backtracking search.

Medium
40

Combination Sum II

Find all unique combinations of numbers that sum to a target using backtracking with careful pruning to avoid duplicates…

Medium
46

Permutations

Generate all possible orderings of a distinct integer array using backtracking search with careful pruning to avoid dupl…

Medium
47

Permutations II

Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…

Medium
51

N-Queens

Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…

Hard
52

N-Queens II

Solve the N-Queens II problem using backtracking with pruning to efficiently count all valid placements for n queens on …

Hard
77

Combinations

Generate all combinations of k numbers from the range [1, n] using backtracking and pruning.

Medium
78

Subsets

Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.

Medium
79

Word Search

Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.

Medium
89

Gray Code

Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.

Medium
90

Subsets II

Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…

Medium
93

Restore IP Addresses

Restore all valid IP addresses from a string using backtracking with pruning, avoiding invalid segments or leading zeros…

Medium
95

Unique Binary Search Trees II

Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.

Medium
113

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.

Medium
126

Word Ladder II

Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …

Hard
131

Palindrome Partitioning

Find all possible palindrome partitioning of a string using backtracking and dynamic programming.

Medium
140

Word Break II

Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.

Hard
212

Word Search II

Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.

Hard
216

Combination Sum III

Find all unique combinations of k numbers adding to n using efficient backtracking with pruning in arrays.

Medium
257

Binary Tree Paths

Find all root-to-leaf paths in a binary tree using DFS and backtracking, constructing strings for each complete path eff…

Easy
282

Expression Add Operators

Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…

Hard
301

Remove Invalid Parentheses

Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…

Hard
306

Additive Number

Additive Number is solved by trying the first two splits, then pruning aggressively while verifying each required sum in…

Medium
357

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…

Medium
401

Binary Watch

Binary Watch involves generating possible times on a binary watch given a number of turned-on LEDs.

Easy
473

Matchsticks to Square

The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…

Medium
491

Non-decreasing Subsequences

Return all possible non-decreasing subsequences with at least two elements from the input array, nums.

Medium
494

Target Sum

Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…

Medium
526

Beautiful Arrangement

The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…

Medium
638

Shopping Offers

Minimize the cost of purchasing items using available special offers with state transition dynamic programming.

Medium
679

24 Game

Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…

Hard
691

Stickers to Spell Word

Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…

Hard
698

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…

Medium
773

Sliding Puzzle

Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …

Hard
784

Letter Case Permutation

Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.

Medium
797

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.

Medium
816

Ambiguous Coordinates

Find all valid 2D coordinate possibilities for an ambiguous input string using backtracking and pruning techniques.

Medium
842

Split Array into Fibonacci Sequence

This problem challenges you to split a string into a Fibonacci-like sequence using backtracking and pruning.

Medium
949

Largest Time for Given Digits

Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.

Medium
967

Numbers With Same Consecutive Differences

Generate all n-digit numbers where consecutive digits differ by k using efficient backtracking and BFS techniques.

Medium
980

Unique Paths III

Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…

Hard
988

Smallest String Starting From Leaf

Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…

Medium
996

Number of Squareful Arrays

Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…

Hard
1079

Letter Tile Possibilities

Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.

Medium
1096

Brace Expansion II

Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…

Hard
1219

Path with Maximum Gold

Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.

Medium
1238

Circular Permutation in Binary Representation

Generate a circular permutation from a range of numbers using backtracking and bit manipulation.

Medium
1239

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…

Medium
1240

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 …

Hard
1255

Maximum Score Words Formed by Letters

Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…

Hard
1286

Iterator for Combination

Implement an iterator that generates all combinations of a given length using efficient backtracking with pruning.

Medium
1307

Verbal Arithmetic Puzzle

Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.

Hard
1415

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.

Medium
1467

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…

Hard
1593

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.

Medium
1601

Maximum Number of Achievable Transfer Requests

Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.

Hard
1655

Distribute Repeating Integers

Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…

Hard
1718

Construct the Lexicographically Largest Valid Sequence

Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…

Medium
1723

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…

Hard
1774

Closest Dessert Cost

Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…

Medium
1799

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 …

Hard
1849

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.

Medium
1863

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.

Easy
1947

Maximum Compatibility Score Sum

Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…

Medium
1980

Find Unique Binary String

Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.

Medium
1986

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.

Medium
2002

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…

Medium
2014

Longest Subsequence Repeated k Times

Find the longest subsequence repeated k times in a string using backtracking search with pruning.

Hard
2044

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…

Medium
2048

Next Greater Numerically Balanced Number

Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.

Medium
2056

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…

Hard
2065

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 …

Hard
2151

Maximum Good People Based on Statements

Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.

Hard
2178

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…

Medium
2212

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…

Medium
2305

Fair Distribution of Cookies

The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…

Medium
2375

Construct Smallest Number From DI String

Construct the lexicographically smallest string that fits the increasing and decreasing conditions of a given pattern.

Medium
2397

Maximum Rows Covered by Columns

Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…

Medium
2597

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…

Medium
2698

Find the Punishment Number of an Integer

Find the punishment number of a given integer using backtracking search with pruning.

Medium
2708

Maximum Strength of a Group

Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…

Medium
2767

Partition String Into Minimum Beautiful Substrings

Partition a binary string into the fewest beautiful substrings using state transition dynamic programming and careful su…

Medium
3211

Generate Binary Strings Without Adjacent Zeros

Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…

Medium
3348

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…

Hard
3376

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…

Medium

Related Patterns

Backtracking LeetCode Problems: 88 Solutions