识别信号
- Do you handle empty input correctly to avoid unnecessary recursion?
- Can you explain how pruning prevents generating invalid or partial combinations?
- Checks if you handle repeated use of candidates correctly.
解题流程
- 1. 明确窗口/状态定义
- 2. 更新状态并维护约束
- 3. 用边界样例验证
常见失分点
- Failing to prune paths when the current combination exceeds the input length, leading to unnecessary recursion.
- Failing to prune when the path sum exceeds the target, causing unnecessary recursion.
- Not sorting candidates first, which complicates duplicate skipping.
推荐题单梯度
电话号码的字母组合
Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…
组合总和
Find all unique combinations of numbers from a distinct array that sum to a target using controlled backtracking search.
组合总和 II
Find all unique combinations of numbers that sum to a target using backtracking with careful pruning to avoid duplicates…
全排列
Generate all possible orderings of a distinct integer array using backtracking search with careful pruning to avoid dupl…
全排列 II
Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…
N 皇后
Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…
N 皇后 II
Solve the N-Queens II problem using backtracking with pruning to efficiently count all valid placements for n queens on …
组合
Generate all combinations of k numbers from the range [1, n] using backtracking and pruning.
子集
Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.
单词搜索
Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.
格雷编码
Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.
子集 II
Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…
复原 IP 地址
Restore all valid IP addresses from a string using backtracking with pruning, avoiding invalid segments or leading zeros…
单词接龙 II
Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …
单词搜索 II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
组合总和 III
Find all unique combinations of k numbers adding to n using efficient backtracking with pruning in arrays.
给表达式添加运算符
Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…
删除无效的括号
Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…
累加数
Additive Number is solved by trying the first two splits, then pruning aggressively while verifying each required sum in…
二进制手表
Binary Watch involves generating possible times on a binary watch given a number of turned-on LEDs.
24 点游戏
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
字母大小写全排列
Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.
模糊坐标
Find all valid 2D coordinate possibilities for an ambiguous input string using backtracking and pruning techniques.
将数组拆分成斐波那契序列
This problem challenges you to split a string into a Fibonacci-like sequence using backtracking and pruning.
给定数字能组成的最大时间
Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.
连续差相同的数字
Generate all n-digit numbers where consecutive digits differ by k using efficient backtracking and BFS techniques.
不同路径 III
Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…
活字印刷
Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.
黄金矿工
Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.
循环码排列
Generate a circular permutation from a range of numbers using backtracking and bit manipulation.
串联字符串的最大长度
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 problem asks for the minimum number of squares required to cover a rectangle …
字母组合迭代器
Implement an iterator that generates all combinations of a given length using efficient backtracking with pruning.
口算难题
Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.
长度为 n 的开心字符串中字典序第 k 小的字符串
Given n and k, find the k-th lexicographical happy string of length n using backtracking search with pruning.
拆分字符串使唯一子字符串的数目最大
Maximize unique substrings in a string using backtracking with pruning and hash tables to track substrings.
最多可达成的换楼请求数目
Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.
构建字典序最大的可行序列
Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…
将字符串拆分为递减的连续值
Check if a string of digits can be split into descending consecutive values where the difference between them is 1.
找出所有子集的异或总和再求和
Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.
重复 K 次的最长子序列
Find the longest subsequence repeated k times in a string using backtracking search with pruning.
统计按位或能得到最大值的子集数目
Determine the number of non-empty subsets that achieve the maximum bitwise OR using efficient backtracking and pruning s…
下一个更大的数值平衡数
Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.
棋盘上有效移动组合的数目
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
最大化一张图中的路径价值
Calculate the maximum path quality in a graph using backtracking and pruning to optimize node visits within time limits …
基于陈述统计最多好人数
Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.
拆分成最多数目的正偶数之和
Determine the largest set of unique positive even integers that sum to a given finalSum using backtracking and greedy se…
射箭比赛中的最大得分
In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…
被列覆盖的最多行数
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
求一个整数的惩罚数
Find the punishment number of a given integer using backtracking search with pruning.
生成不含相邻零的二进制字符串
Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…
最小可整除数位乘积 II
Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…