面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
电话号码的字母组合
Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…
括号生成
Generate Parentheses requires generating all valid combinations of parentheses with given pairs using backtracking and s…
解数独
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
组合总和
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
Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.
路径总和 II
Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.
单词接龙 II
Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …
分割回文串
Find all possible palindrome partitioning of a string using backtracking and dynamic programming.
单词拆分 II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
单词搜索 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.
二叉树的所有路径
Find all root-to-leaf paths in a binary tree using DFS and backtracking, constructing strings for each complete path eff…
给表达式添加运算符
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…
统计各位数字都不同的数字个数
The problem asks to count numbers with unique digits from 0 to 10^n using dynamic programming, math, and backtracking te…
二进制手表
Binary Watch involves generating possible times on a binary watch given a number of turned-on LEDs.
火柴拼正方形
The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…
非递减子序列
Return all possible non-decreasing subsequences with at least two elements from the input array, nums.
目标和
Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…
优美的排列
The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…
大礼包
Minimize the cost of purchasing items using available special offers with state transition dynamic programming.
24 点游戏
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
贴纸拼词
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
划分为k个相等的子集
Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…
滑动谜题
Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …
字母大小写全排列
Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.
所有可能的路径
Find all paths in a directed acyclic graph (DAG) from source to target using depth-first search and backtracking.
模糊坐标
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…
从叶结点开始的最小字符串
Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…
平方数组的数目
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
活字印刷
Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.
花括号展开 II
Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…
黄金矿工
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 …
得分最高的单词集合
Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…
字母组合迭代器
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.
两个盒子中球的颜色数相同的概率
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
拆分字符串使唯一子字符串的数目最大
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.
分配重复整数
Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…
构建字典序最大的可行序列
Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…
完成所有工作的最短时间
Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…
最接近目标价格的甜点成本
Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…
N 次操作后的最大分数和
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
将字符串拆分为递减的连续值
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.
最大兼容性评分和
Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…
找出不同的二进制字符串
Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.
完成任务的最少工作时间段
Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.
两个回文子序列长度的最大乘积
Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…
重复 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…
公平分发饼干
The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…
根据模式串构造最小数字
Construct the lexicographically smallest string that fits the increasing and decreasing conditions of a given pattern.
被列覆盖的最多行数
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
美丽子集的数目
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 a given integer using backtracking search with pruning.
一个小组的最大实力值
Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…
将字符串分割为最少的美丽子字符串
Partition a binary string into the fewest beautiful substrings using state transition dynamic programming and careful su…
生成不含相邻零的二进制字符串
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…
破解锁的最少时间 I
Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…