面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
最长连续序列
Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.
被围绕的区域
Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.
岛屿数量
Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…
除法求值
Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.
省份数量
Solve Number of Provinces by scanning the adjacency matrix and launching DFS once per unvisited city component.
冗余连接
Identify and remove the redundant edge that causes a cycle in a graph starting as a tree.
冗余连接 II
Find and remove the redundant connection in a directed graph that was originally a rooted tree.
岛屿的最大面积
Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.
账户合并
Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…
情侣牵手
This problem requires arranging couples sitting apart in a row with the minimum number of swaps using graph traversal an…
水位上升的泳池中游泳
Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.
判断二分图
Determine whether an undirected graph can be split into two independent sets using DFS, BFS, or Union Find patterns.
打砖块
Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.
最大人工岛
Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…
相似字符串组
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
可能的二分法
Determine if a group of n people with mutual dislikes can be split into two non-conflicting groups using graph traversal…
尽量减少恶意软件的传播
Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.
尽量减少恶意软件的传播 II
Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.
移除最多的同行或同列石头
Maximize the number of stones removed from a 2D plane using graph traversal and DFS.
按公因数计算最大组件大小
Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …
由斜杠划分区域
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
等式方程的可满足性
Determine if it's possible to assign values to variables such that all equations are satisfied based on equality and ine…
飞地的数量
This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…
按字典序排列最小的等效字符串
Determine the lexicographically smallest string by modeling character equivalences with union find efficiently.
交换字符串中的元素
Find the lexicographically smallest string by swapping characters in given pairs of indices.
统计封闭岛屿的数目
Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.
统计参与通信的服务器
Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…
连通网络的操作次数
Determine the minimum number of operations required to connect all computers in a network with a limited number of cable…
验证二叉树
Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.
检查网格中是否存在有效路径
Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.
找到最小生成树里的关键边和伪关键边
Identify critical and pseudo-critical edges in a weighted graph's minimum spanning tree using Union Find efficiently.
二维网格图中探测环
Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.
将子数组重新排序得到同一个二叉搜索树的方案数
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
保证图可完全遍历
Maximize the number of edges that can be removed while keeping the graph fully traversable for both Alice and Bob.
连接所有点的最小费用
Min Cost to Connect All Points asks for the minimum cost to connect all points on a 2D plane, using manhattan distances …
带阈值的图连通性
In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…
最小体力消耗路径
Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…
矩阵转换后的排名
Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…
检查边长度限制的路径是否存在
Solve the problem of checking if there exists a path between two nodes under edge length constraints using efficient tec…
执行交换操作后的最小汉明距离
Solve Minimize Hamming Distance After Swap Operations by grouping swappable indices and matching value counts inside eac…
统计子岛屿
Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…
你能穿过矩阵的最后一天
Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.
寻找图中是否存在路径
Determine if a valid path exists between two vertices in a bi-directional graph using traversal techniques.
数组的最大公因数排序
The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.
每棵子树内缺失的最小基因值
Determine the smallest missing genetic value in each subtree using binary-tree traversal and precise state tracking effi…
处理含限制条件的好友请求
Determine which friend requests can be accepted without violating direct or indirect restrictions using union-find logic…
找出知晓秘密的所有专家
Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…
字符串分组
Group words into connected sets using operations on characters with string and bit manipulation techniques.
统计无向图中无法互相到达点对数
Calculate the total number of node pairs in an undirected graph that cannot reach each other using DFS, BFS, or Union Fi…
元素值大于变化阈值的子数组
Find the size of a subarray with all elements greater than threshold divided by length using stack-based state managemen…
受限条件下可到达节点的数目
In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…
删除操作后的最大子段和
Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…
好路径的数目
Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.
最长上传前缀
Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…
两个城市间路径的最小分数
Find the minimum distance in a path connecting two cities using graph traversal strategies efficiently.
将节点分成尽可能多的组
Determine the maximum number of groups nodes can form in a graph using depth-first traversal without violating edge conn…
矩阵查询可获得的最大分数
Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.
找出对应 LCP 矩阵的字符串
Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.
网格图中最少访问的格子数
Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…
网格图中鱼的最大数目
Maximize the number of fish that can be caught by performing DFS on an optimal starting point in a grid.
统计完全连通分量的数量
Determine the number of complete connected components in an undirected graph using efficient traversal techniques and gr…
最大公约数遍历
Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.
找出最安全路径
Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.
交换得到字典序最小的数组
Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.
带权图里旅途的最小代价
Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…
判断矩形的两个角落是否可达
Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.
统计最小公倍数图中的连通块数目
Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…
属性图
Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…
针对图的路径存在性查询 I
Determine if paths exist between nodes using array scanning and hash lookups for efficient component checks in graphs.
升级后最大生成树稳定性
Maximizing the stability of a spanning tree with upgrades requires careful optimization of edge strengths using binary s…
电网维护
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
包含 K 个连通分量需要的最小时间
Find the minimum time to remove edges such that a graph with n nodes has at least k connected components.
最小化连通分量的最大成本
Minimize Maximum Component Cost leverages binary search over edge weights to optimize the cost of graph components after…
总价值可以被 K 整除的岛屿数目
Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.