面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
课程表
Determine if all courses can be completed by analyzing prerequisite dependencies using indegree tracking and topological…
课程表 II
Solve the 'Course Schedule II' problem using graph indegree and topological ordering, utilizing DFS or BFS to find the c…
最小高度树
Identify all roots of a tree that produce minimum height using graph indegree analysis and topological trimming.
矩阵中的最长递增路径
Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.
找到最终的安全状态
Solve the problem of finding eventual safe states in a directed graph using depth-first search and topological sorting.
喧闹和富有
Determine the quietest person richer than each individual using graph indegree analysis and topological ordering techniq…
猫和老鼠
Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…
项目管理
Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…
课程表 IV
Determine if one course is a prerequisite of another using graph indegree tracking and topological ordering efficiently.
奇怪的打印机 II
Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…
矩阵转换后的排名
Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…
猫和老鼠 II
Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…
从第一个节点出发到最后一个节点的受限路径数
Solve the problem of finding the number of restricted paths in a weighted undirected graph, leveraging graph algorithms …
有向图中最大颜色值
Compute the maximum color frequency along any valid path in a directed graph using topological ordering and dynamic prog…
统计为蚁群构筑房间的不同顺序
Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…
到达目的地的方案数
Find the number of ways to travel from intersection 0 to n - 1 in the shortest time, using a graph-based approach.
并行课程 III
Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…
从给定原材料中找到所有可以做出的菜
Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …
参加会议的最多员工数
Determine the maximum employees to invite based on favorite adjacency constraints using graph indegree and topological o…
有向无环图中一个节点的所有祖先
Solve the All Ancestors of a Node in a Directed Acyclic Graph problem using graph traversal techniques like BFS, DFS, an…
相邻字符不同的最长路径
Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…
网格图中递增路径的数目
Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…
图中的最长环
The problem asks to find the longest cycle in a directed graph with specific edge constraints.
给定条件下构造矩阵
Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…
收集树中金币
The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…
最短公共超序列的字母出现频率
Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …
有向无环图中合法拓扑排序的最大利润
Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…
恢复网络路径
Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.