面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
单词搜索
Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.
二叉树的中序遍历
Binary Tree Inorder Traversal asks you to visit left subtree, node, then right subtree without losing position while mov…
验证二叉搜索树
Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…
恢复二叉搜索树
Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…
相同的树
Check whether two binary trees are identical by comparing structure and node values using DFS or BFS traversal strategie…
对称二叉树
Determine if a binary tree is symmetric by comparing left and right subtrees using DFS or BFS traversal techniques effic…
二叉树的最大深度
Find the maximum depth of a binary tree using traversal techniques to track the longest path from root to leaf.
平衡二叉树
Determine if a binary tree is height-balanced using tree traversal and state tracking techniques.
二叉树的最小深度
Find the minimum depth of a binary tree, which is the shortest path from the root node to the nearest leaf node.
路径总和
Determine if a binary tree has a root-to-leaf path where the sum of node values equals a given target sum, using DFS or …
路径总和 II
Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.
二叉树展开为链表
Flatten a binary tree into a right-skewed linked list by manipulating pointers following a pre-order traversal, handling…
填充每个节点的下一个右侧节点指针
Connect each node across every level by reusing established next links to traverse a perfect binary tree without extra q…
填充每个节点的下一个右侧节点指针 II
Populate each next pointer in a binary tree to its immediate right node, handling nulls and uneven levels efficiently us…
二叉树中的最大路径和
Calculate the maximum sum of any path in a binary tree by exploring all node sequences using DFS and dynamic programming…
求根节点到叶节点数字之和
Calculate the sum of all root-to-leaf numbers in a binary tree where each path represents a number.
被围绕的区域
Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.
克隆图
Clone Graph involves cloning a graph using DFS, focusing on graph traversal and neighbor management using hash tables.
二叉树的前序遍历
Perform a binary tree preorder traversal by visiting root nodes first, then left and right subtrees, tracking state iter…
二叉树的后序遍历
Solve Binary Tree Postorder Traversal using state tracking and binary-tree traversal techniques, focusing on Stack, Tree…
二叉树的右视图
The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…
岛屿数量
Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…
课程表 II
Solve the 'Course Schedule II' problem using graph indegree and topological ordering, utilizing DFS or BFS to find the c…
添加与搜索单词 - 数据结构设计
Build a WordDictionary supporting dynamic word addition and search with wildcard matching efficiently using Trie and DFS…
翻转二叉树
Invert Binary Tree swaps every node's left and right children using tree traversal, with recursive DFS or iterative BFS …
二叉搜索树中第 K 小的元素
Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.
二叉搜索树的最近公共祖先
Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…
二叉树的最近公共祖先
Identify the lowest common ancestor of two nodes in a binary tree using traversal and state tracking techniques efficien…
二叉树的所有路径
Find all root-to-leaf paths in a binary tree using DFS and backtracking, constructing strings for each complete path eff…
二叉树的序列化与反序列化
This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…
最小高度树
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.
重新安排行程
Reconstruct Itinerary requires building a valid travel route using all tickets once, starting from JFK with lexical orde…
打家劫舍 III
Maximize the loot by robbing non-adjacent houses in a binary tree structure using dynamic programming and DFS.
扁平化嵌套列表迭代器
Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.
水壶问题
Determine if two jugs with given capacities can measure an exact target amount using math and DFS strategies efficiently…
迷你语法分析器
Deserialize a nested list string using stack-based state management, handling integers and nested lists with depth-first…
字典序排数
Generate all numbers from 1 to n in lexicographical order using a depth-first search pattern optimized with trie logic f…
文件的最长绝对路径
Find the length of the longest absolute file path in a filesystem string using stack-based depth tracking efficiently.
除法求值
Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.
左叶子之和
Compute the total of all left leaves in a binary tree using precise traversal and state tracking techniques for correctn…
太平洋大西洋水流问题
Find all cells on an island where water can flow to both the Pacific and Atlantic oceans using DFS or BFS.
棋盘上的战舰
Count the number of non-overlapping battleships on a 2D board using array traversal and depth-first search patterns effi…
扁平化多级双向链表
Flatten a multilevel doubly linked list by correctly updating next, prev, and child pointers to create a single-level se…
路径总和 III
Path Sum III challenges you to count paths in a binary tree that sum to a given target value with downward traversal.
序列化和反序列化二叉搜索树
Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.
岛屿的周长
Determine the perimeter of an island in a grid of land and water cells using DFS or BFS.
连接词
Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …
二叉搜索树中的众数
Find Mode in Binary Search Tree asks to identify the most frequent element(s) in a BST using binary-tree traversal.
出现次数最多的子树元素和
Identify the most frequent subtree sum in a binary tree using DFS and hash table tracking for efficient state management…
找树左下角的值
Find the leftmost value in the last row of a binary tree using efficient traversal strategies.
自由之路
Determine the minimum rotations and button presses to spell a keyword on a circular dial using state transition dynamic …
在每个树行中找最大值
Find the largest value in each row of a binary tree using depth-first or breadth-first search techniques.
扫雷游戏
Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…
二叉搜索树的最小绝对差
Find the minimum absolute difference between values of any two nodes in a BST using tree traversal and careful state tra…
把二叉搜索树转换为累加树
Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.
二叉树的直径
The Diameter of Binary Tree problem involves finding the longest path between any two nodes using tree traversal techniq…
省份数量
Solve Number of Provinces by scanning the adjacency matrix and launching DFS once per unvisited city component.
N 叉树的最大深度
Find the maximum depth of an N-ary tree, leveraging tree traversal techniques and state tracking.
二叉树的坡度
Calculate the sum of the binary tree's node tilts using tree traversal and state tracking.
数组嵌套
Find the longest nested set in a permutation array using a depth-first traversal, handling cycles efficiently for medium…
另一棵树的子树
Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.
N 叉树的前序遍历
Solve the N-ary Tree Preorder Traversal problem using depth-first search and stack-based traversal methods.
N 叉树的后序遍历
Postorder traversal of an N-ary tree can be efficiently solved using DFS and stack-based methods, tracking state across …
根据二叉树创建字符串
Given a binary tree, construct a string representation based on preorder traversal while adhering to specific formatting…
合并二叉树
Merge Two Binary Trees requires combining nodes by summing overlapping values while preserving non-null nodes from eithe…
在二叉树中增加一行
The problem requires adding a row of nodes to a binary tree at a specified depth.
二叉树的层平均值
Calculate the average value of nodes on each level of a binary tree using traversal and state tracking.
寻找重复的子树
Identify all duplicate subtrees in a binary tree by efficiently tracking structure and values with depth-first traversal…
两数之和 IV - 输入二叉搜索树
Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…
输出二叉树
Print Binary Tree requires arranging a binary tree into a visually structured matrix using precise traversal and positio…
二叉树最大宽度
Determine the maximum width of a binary tree by calculating the width of each level and considering the positions of the…
修剪二叉搜索树
Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.
二叉树中第二小的节点
Find the second minimum node in a binary tree by traversing the tree and tracking state.
灯泡开关 Ⅱ
Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.
实现一个魔法字典
Design a Magic Dictionary to allow searching with one-character modifications, using Hash Table and String techniques.
冗余连接
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 longest path in a binary tree where all nodes share the same value using depth-first search efficiently.
员工的重要性
Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…
岛屿的最大面积
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…
图像渲染
Flood Fill is an array and DFS problem where you change connected pixels to a target color efficiently using recursion o…
网络延迟时间
Find the minimum time for a signal to travel to all nodes in a directed graph or determine if it's impossible.
隔离病毒
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
破解保险箱
The Cracking the Safe problem involves finding the shortest password sequence to unlock a safe using graph traversal and…
金字塔转换矩阵
The Pyramid Transition Matrix problem requires determining whether a pyramid can be formed with given blocks and valid p…
情侣牵手
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.
二叉搜索树节点最小距离
Find the minimum difference between values of two different nodes in a Binary Search Tree using tree traversal and state…
判断二分图
Determine whether an undirected graph can be split into two independent sets using DFS, BFS, or Union Find patterns.
K 站中转内最便宜的航班
Find the cheapest flight from a source to a destination with at most K stops using graph traversal techniques efficientl…
所有可能的路径
Find all paths in a directed acyclic graph (DAG) from source to target using depth-first search and backtracking.
找到最终的安全状态
Solve the problem of finding eventual safe states in a directed graph using depth-first search and topological sorting.
二叉树剪枝
Binary Tree Pruning removes subtrees not containing a 1, applying binary-tree traversal with state tracking.
最大人工岛
Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…
树中距离之和
The problem asks to compute the sum of distances between each node and all others in a tree structure using depth-first …
相似字符串组
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
钥匙和房间
Determine if all rooms can be visited given keys distributed across a set of interconnected locked rooms using graph tra…
喧闹和富有
Determine the quietest person richer than each individual using graph indegree analysis and topological ordering techniq…
二叉树中所有距离为 K 的结点
Find all nodes at distance K from a target node in a binary tree using various tree traversal techniques.
具有所有最深节点的最小子树
Find the smallest subtree that contains all the deepest nodes in a binary tree.
叶子相似的树
Determine if two binary trees have identical leaf sequences using efficient traversal and state tracking techniques.
可能的二分法
Determine if a group of n people with mutual dislikes can be split into two non-conflicting groups using graph traversal…
递增顺序搜索树
Rearrange a binary search tree so all nodes follow increasing order with only right children using in-order 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.
最短的桥
Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.
二叉搜索树的范围和
Given a BST and a range, calculate the sum of all node values within that range.
移除最多的同行或同列石头
Maximize the number of stones removed from a 2D plane using graph traversal and DFS.
翻转等价二叉树
Determine if two binary trees are flip equivalent by recursively swapping subtrees.
由斜杠划分区域
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
单值二叉树
Determine if a binary tree is uni-valued using traversal and state tracking techniques.
监控二叉树
Determine the minimum number of cameras required to monitor every node in a binary tree using efficient DFS and state tr…
翻转二叉树以匹配先序遍历
Determine the minimum set of nodes to flip in a binary tree so its pre-order traversal matches a given voyage sequence.
在二叉树中分配硬币
Minimize the number of moves needed to distribute coins in a binary tree so that each node has exactly one coin.
二叉树的垂序遍历
Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.
从叶结点开始的最小字符串
Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…
二叉树的堂兄弟节点
Determine if two nodes in a binary tree are cousins by leveraging binary-tree traversal and state tracking.
飞地的数量
This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…
从根到叶的二进制数之和
Calculate the sum of binary numbers from root to leaf paths in a binary tree.
节点与其祖先之间的最大差值
Find the maximum absolute difference between a node and its ancestor in a binary tree.
从先序遍历还原二叉树
Recover a binary tree from its preorder traversal string by tracking node depth and reconstructing child relationships e…
边界着色
Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …
逃离大迷宫
The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…
从二叉搜索树到更大和树
Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…
不邻接植花
In this problem, you are tasked with planting flowers in gardens with specific constraints based on graph traversal prin…
根到叶路径上的不足节点
Remove nodes in a binary tree whose all root-to-leaf paths sum to less than a given limit using DFS traversal and state …
删点成林
Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.
最深叶节点的最近公共祖先
Find the lowest common ancestor of the deepest leaves in a binary tree using efficient traversal and state tracking tech…
二叉树着色游戏
A two-player game where players color nodes in a binary tree, aiming to outmaneuver each other by choosing adjacent node…
最大层内元素和
Find the level of a binary tree where the sum of its nodes is maximal, with an emphasis on binary-tree traversal.
查找集群内的关键连接
Find critical connections in a network of servers, ensuring efficient traversal using depth-first search and Tarjan's al…
交换字符串中的元素
Find the lexicographically smallest string by swapping characters in given pairs of indices.
项目管理
Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…
删除子文件夹
Remove sub-folders in a filesystem by filtering out folders nested inside other folders.
统计封闭岛屿的数目
Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.
在受污染的二叉树中查找元素
Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…
统计参与通信的服务器
Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…
层数最深叶子节点的和
Find the sum of the deepest leaves in a binary tree by using tree traversal and state tracking techniques.
两棵二叉搜索树中的所有元素
Merge elements from two binary search trees and return them sorted in ascending order.
跳跃游戏 III
Jump Game III challenges you to determine if you can reach any zero in an array using jumps defined by array values, tes…
祖父节点值为偶数的节点和
This problem involves calculating the sum of nodes with an even-valued grandparent in a binary tree.
连通网络的操作次数
Determine the minimum number of operations required to connect all computers in a network with a limited number of cable…
删除给定值的叶子节点
In this problem, you need to delete all leaf nodes in a binary tree with a given target value, performing continuous del…
分裂二叉树的最大乘积
Maximize the product of sums of two subtrees formed by splitting a binary tree.
验证二叉树
Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.
二叉树中的链表
Determine if a linked list is represented as a downward path in a binary tree using pointer traversal and recursive chec…
二叉树中的最长交错路径
Find the longest ZigZag path in a binary tree using depth-first search and dynamic programming for precise node state tr…
二叉搜索子树的最大键值和
Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.
通知所有员工所需的时间
Calculate the time needed for the head of a company to inform all employees using tree traversal techniques.
T 秒后青蛙的位置
The problem asks for the probability that a frog reaches a target vertex after t seconds in a tree graph.
找出克隆二叉树中的相同节点
Find the corresponding node in a cloned binary tree using binary-tree traversal and state tracking.
将二叉搜索树变平衡
This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.
检查网格中是否存在有效路径
Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.
收集树上所有苹果的最少时间
Minimize the time spent to collect all apples in a tree, considering traversal and state tracking with binary tree techn…
统计二叉树中好节点的数目
Count Good Nodes in Binary Tree identifies nodes exceeding all previous values along their path using DFS traversal tech…
二叉树中的伪回文路径
Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.
课程表 IV
Determine if one course is a prerequisite of another using graph indegree tracking and topological ordering efficiently.
重新规划路线
Reorder Routes to Make All Paths Lead to the City Zero involves reversing the direction of roads in a tree to ensure all…
树节点的第 K 个祖先
Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.
子树中标签相同的节点数
Compute the number of nodes in each subtree sharing the same label using DFS with hash table aggregation efficiently.
好叶子节点对的数量
Find the number of good leaf node pairs in a binary tree where the shortest path between them is less than or equal to a…
二维网格图中探测环
Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.
使陆地分离的最少天数
Find the minimum number of days to disconnect an island in a grid using depth-first search.
王位继承顺序
Throne Inheritance requires modeling a dynamic family tree with births and deaths to determine the kingdom's inheritance…
执行操作后字典序最小的字符串
Optimize a string through rotations and additions to get the lexicographically smallest possible result using string man…
最小体力消耗路径
Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…
执行交换操作后的最小汉明距离
Solve Minimize Hamming Distance After Swap Operations by grouping swappable indices and matching value counts inside eac…
从相邻元素对还原数组
Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…
互质树
Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…
统计子岛屿
Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…
合并多棵二叉搜索树
This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.
查询最大基因差
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
你能穿过矩阵的最后一天
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.
找到所有的农场组
Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.
树上的操作
Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.
每棵子树内缺失的最小基因值
Determine the smallest missing genetic value in each subtree using binary-tree traversal and precise state tracking effi…
统计最高分的节点数目
Find the number of nodes with the highest score in a binary tree, based on subtree sizes and node removal.
找出知晓秘密的所有专家
Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…
从二叉树一个节点到另一个节点每一步的方向
Find the shortest path between two nodes in a binary tree and output the directions as a string of 'L', 'R', and 'U'.
合法重新排列数对
Given pairs of numbers, find a valid arrangement where each pair follows a specific condition.
引爆最多的炸弹
Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …
参加会议的最多员工数
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…
统计值等于子树平均值的节点数
Given a binary tree, count nodes where the value equals the average of values in its subtree.
统计无向图中无法互相到达点对数
Calculate the total number of node pairs in an undirected graph that cannot reach each other using DFS, BFS, or Union Fi…
从树中删除边的最小分数
Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.
网格图中递增路径的数目
Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…
计算布尔二叉树的值
Determine the boolean outcome of a full binary tree by evaluating leaf and internal nodes using depth-first traversal.
找到离给定两个节点最近的节点
Find the node that minimizes the maximum distance to two given nodes in a directed graph with one outgoing edge per node…
图中的最长环
The problem asks to find the longest cycle in a directed graph with specific edge constraints.
受限条件下可到达节点的数目
In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…
感染二叉树需要的总时间
The problem asks to calculate the number of minutes for an infection to spread across all nodes in a binary tree startin…
反转二叉树的奇数层
Reverse the node values at each odd level in a perfect binary tree, preserving the even levels.
创建价值相同的连通块
Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.
移除子树后的二叉树高度
Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…
树上最大得分和路径
Solve the 'Most Profitable Path in a Tree' problem using graph traversal and depth-first search techniques to maximize A…
二叉搜索树最近节点查询
Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…
到达首都的最少油耗
Calculate the minimum fuel needed for all city representatives to reach the capital using DFS on a tree graph efficientl…
两个城市间路径的最小分数
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…
最大价值和与最小价值和的差值
Compute the maximum difference between any path price sum in a tree using binary-tree traversal and state tracking effic…
二进制矩阵中翻转最多一次使路径不连通
Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…
统计可能的树根数目
Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.
检查骑士巡视方案
Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.
二叉树的堂兄弟节点 II
Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.
最小化旅行的价格总和
Calculate the minimum total cost of multiple trips on a tree by selectively halving node prices using DFS frequency coun…
网格图中鱼的最大数目
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…
树中可以形成回文的路径数
This problem asks you to count all node pairs in a tree whose path characters can be rearranged into a palindrome using …
可以到达每一个节点的最少边反转次数
This problem requires solving a graph traversal with edge reversals to ensure every node is reachable in a tree-like str…
统计树中的合法路径数目
Count Valid Paths in a Tree involves finding paths with exactly one prime number in a tree of n nodes.
可以被 K 整除连通块的最大数目
Determine the maximum number of connected components in a tree where each component sum is divisible by k using DFS.
收集所有金币可获得的最大积分
Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.
在树上执行操作以后得到的最大分数
Solve Maximum Score After Applying Operations on a Tree by turning healthy-path constraints into subtree DP and forced-v…
树中每个节点放置的金币数目
Determine the exact number of coins to place on each tree node using subtree cost products and DFS tracking.
在带权树网络中统计可连接服务器对数目
This problem involves counting pairs of connectable servers in a weighted tree network using binary-tree traversal and D…
最短路径中的边
Use two Dijkstra runs to mark exactly which edges can appear on at least one shortest path from 0 to n - 1.
合并两棵树后的最小直径
Calculate the minimum diameter after merging two trees by strategically connecting nodes to minimize the longest path in…
判断矩形的两个角落是否可达
Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.
标记所有节点需要的时间
Calculate the time taken to mark all nodes in a tree, starting from any node with time t=0.
统计好节点的数目
Determine how many nodes in a binary tree have all child subtrees of equal size using DFS traversal efficiently.
移除可疑的方法
Remove suspicious methods in a project that are invoked directly or indirectly from a buggy method using graph traversal…
第 K 大的完美二叉子树的大小
Find the size of the kth largest perfect subtree in a binary tree using tree traversal and state tracking.
判断 DFS 字符串是否是回文串
Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…
修改后子树的大小
Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…
移除边之后的权重最大和
Maximize the sum of edge weights in a tree after removals, using dynamic programming and tree traversal techniques.
连接两棵树后最大目标节点数目 I
Maximize the number of target nodes after connecting two trees using binary tree traversal and state tracking.
连接两棵树后最大目标节点数目 II
Maximize the number of target nodes after connecting two trees by analyzing their structure and target relationships.
破解锁的最少时间 I
Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…
两天自由外汇交易后的最大货币数
Compute the maximum currency amount after two days using graph traversal and depth-first search for optimal conversions.
图的最大边权的最小值
Minimize the maximum edge weight in a graph after removing certain edges while ensuring node reachability.
最长特殊路径
Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.
最长特殊路径 II
Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…
属性图
Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…
带权树中的最短路径
Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.
单位转换 I
Solve the unit conversion problem by using graph traversal to compute equivalent unit amounts.
子树反转和
This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…
图中边值的最大和
Maximize the sum of edge values in a connected graph by assigning unique node values and optimizing edge products.
包含要求路径的最小带权子图 II
Solve the Minimum Weighted Subgraph With the Required Paths II problem by leveraging binary-tree traversal and efficient…
给边赋权值的方案数 I
Calculate the number of valid edge weight assignments in a tree using DFS and binary-tree traversal with careful state t…
给边赋权值的方案数 II
This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.
折扣价交易股票的最大利润
Solve the Maximum Profit from Trading Stocks with Discounts problem using binary-tree traversal and dynamic state tracki…
最大好子树分数
Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…
树中找到带权中位节点
Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…
第 K 小的路径异或和
This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…
使叶子路径成本相等的最小增量
Find the minimum number of increments needed to equalize leaf path scores in a tree with different node costs.
电网维护
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
总价值可以被 K 整除的岛屿数目
Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.