leetcode.com 2025-10-06
🔴778.swim-in-rising-water
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
🔴778.swim-in-rising-water
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
Telegraph
swim-in-rising-water
You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j). It starts raining, and water gradually rises over time. At time t, the water level is t, meaning any cell with elevation less than equal…
leetcode.cn 2025-10-19
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
Telegraph
lexicographically-smallest-string-after-applying-operations
给你一个字符串 s 以及两个整数 a 和 b 。其中,字符串 s 的长度为偶数,且仅由数字 0 到 9 组成。 你可以在 s 上按任意顺序多次执行下面两个操作之一:
leetcode.com 2025-10-19
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
Telegraph
lexicographically-smallest-string-after-applying-operations
You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b. You can apply either of the following two operations any number of times and in any order on s:
leetcode.cn 2025-11-06
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
Telegraph
power-grid-maintenance
给你一个整数 c,表示 c 个电站,每个电站有一个唯一标识符 id,从 1 到 c 编号。 这些电站通过 n 条 双向 电缆互相连接,表示为一个二维数组 connections,其中每个元素 connections[i] = [ui, vi] 表示电站 ui 和电站 vi 之间的连接。直接或间接连接的电站组成了一个 电网 。 最初,所有 电站均处于在线(正常运行)状态。 另给你一个二维数组 queries,其中每个查询属于以下 两种类型之一 :
leetcode.com 2025-11-06
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
Telegraph
power-grid-maintenance
You are given an integer c representing c power stations, each with a unique identifier id from 1 to c (1‑based indexing). These stations are interconnected via n bidirectional cables, represented by a 2D array connections, where each element connections[i]…
leetcode.cn 2025-12-19
🔴2092.find-all-people-with-secret
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #sorting
🔴2092.find-all-people-with-secret
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #sorting
Telegraph
find-all-people-with-secret
给你一个整数 n ,表示有 n 个专家从 0 到 n - 1 编号。另外给你一个下标从 0 开始的二维整数数组 meetings ,其中 meetings[i] = [xi, yi, timei] 表示专家 xi 和专家 yi 在时间 timei 要开一场会。一个专家可以同时参加 多场会议 。最后,给你一个整数 firstPerson 。 专家 0 有一个 秘密 ,最初,他在时间 0 将这个秘密分享给了专家 firstPerson 。接着,这个秘密会在每次有知晓这个秘密的专家参加会议时进行传播。更正式的表达是,每次会议,如果专家…
leetcode.com 2025-12-19
🔴2092.find-all-people-with-secret
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #sorting
🔴2092.find-all-people-with-secret
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #sorting
Telegraph
find-all-people-with-secret
You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend…
leetcode.cn 2025-12-31
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
Telegraph
last-day-where-you-can-still-cross
给你一个下标从 1 开始的二进制矩阵,其中 0 表示陆地,1 表示水域。同时给你 row 和 col 分别表示矩阵中行和列的数目。 一开始在第 0 天,整个 矩阵都是 陆地 。但每一天都会有一块新陆地被 水 淹没变成水域。给你一个下标从 1 开始的二维数组 cells ,其中 cells[i] = [ri, ci] 表示在第 i 天,第 ri 行 ci 列(下标都是从 1 开始)的陆地会变成 水域 (也就是 0 变成 1 )。 你想知道从矩阵最 上面 一行走到最 下面 一行,且只经过陆地格子的 最后一天…
leetcode.com 2025-12-31
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
Telegraph
last-day-where-you-can-still-cross
There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively. Initially on day 0, the entire matrix is land. However, each day a…
leetcode.cn 2026-01-06
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
maximum-level-sum-of-a-binary-tree
给你一个二叉树的根节点 root。设根节点位于二叉树的第 1 层,而根节点的子节点位于第 2 层,依此类推。 返回总和 最大 的那一层的层号 x。如果有多层的总和一样大,返回其中 最小 的层号 x。 示例 1: 输入:root = [1,7,0,7,-8,null,null] 输出:2 解释: 第 1 层各元素之和为 1, 第 2 层各元素之和为 7 + 0 = 7, 第 3 层各元素之和为 7 + -8 = -1, 所以我们返回第 2 层的层号,它的层内元素之和最大。 示例 2: 输入:root =…
leetcode.com 2026-01-06
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
maximum-level-sum-of-a-binary-tree
Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1: Input: root = [1,7,0,7,-8,null,null] Output:…
leetcode.cn 2026-01-09
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
smallest-subtree-with-all-the-deepest-nodes
给定一个根为 root 的二叉树,每个节点的深度是 该节点到根的最短距离 。 返回包含原始树中所有 最深节点 的 最小子树 。 如果一个节点在 整个树 的任意节点之间具有最大的深度,则该节点是 最深的 。 一个节点的 子树 是该节点加上它的所有后代的集合。 示例 1: 输入:root = [3,5,1,6,2,0,8,null,null,7,4] 输出:[2,7,4] 解释: 我们返回值为 2 的节点,在图中用黄色标记。 在图中用蓝色标记的是树的最深的节点。 注意,节点 5、3 和 2 包含树中最深的节点,但节点…
leetcode.com 2026-01-09
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
smallest-subtree-with-all-the-deepest-nodes
Given the root of a binary tree, the depth of each node is the shortest distance to the root. Return the smallest subtree such that it contains all the deepest nodes in the original tree. A node is called the deepest if it has the largest depth possible among…
leetcode.cn 2026-02-27
🔴3666.minimum-operations-to-equalize-binary-string
🏷️ Tags
#breadth_first_search #union_find #math #string #ordered_set
🔴3666.minimum-operations-to-equalize-binary-string
🏷️ Tags
#breadth_first_search #union_find #math #string #ordered_set
Telegraph
minimum-operations-to-equalize-binary-string
给你一个二进制字符串 s 和一个整数 k。
leetcode.cn 2026-04-26
🟡1559.detect-cycles-in-2d-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡1559.detect-cycles-in-2d-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
detect-cycles-in-2d-grid
给你一个二维字符网格数组 grid ,大小为 m x n ,你需要检查 grid 中是否存在 相同值 形成的环。 一个环是一条开始和结束于同一个格子的长度 大于等于 4 的路径。对于一个给定的格子,你可以移动到它上、下、左、右四个方向相邻的格子之一,可以移动的前提是这两个格子有 相同的值 。 同时,你也不能回到上一次移动时所在的格子。比方说,环 (1, 1) -> (1, 2) -> (1, 1) 是不合法的,因为从 (1, 2) 移动到 (1, 1) 回到了上一次移动时的格子。 如果 grid 中有相同值形成的环,请你返回…
leetcode.com 2026-04-26
🟡1559.detect-cycles-in-2d-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡1559.detect-cycles-in-2d-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
detect-cycles-in-2d-grid
Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid. A cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to…
leetcode.cn 2026-04-27
🟡1391.check-if-there-is-a-valid-path-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡1391.check-if-there-is-a-valid-path-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
check-if-there-is-a-valid-path-in-a-grid
给你一个 m x n 的网格 grid。网格里的每个单元都代表一条街道。grid[i][j] 的街道可以是:
leetcode.com 2026-04-27
🟡1391.check-if-there-is-a-valid-path-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡1391.check-if-there-is-a-valid-path-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
check-if-there-is-a-valid-path-in-a-grid
You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be:
leetcode.cn 2026-05-08
🟡3629.minimum-jumps-to-reach-end-via-prime-teleportation
🏷️ Tags
#breadth_first_search #array #hash_table #math #number_theory
🟡3629.minimum-jumps-to-reach-end-via-prime-teleportation
🏷️ Tags
#breadth_first_search #array #hash_table #math #number_theory
Telegraph
minimum-jumps-to-reach-end-via-prime-teleportation
给你一个长度为 n 的整数数组 nums。
leetcode.com 2026-05-08
🟡3629.minimum-jumps-to-reach-end-via-prime-teleportation
🏷️ Tags
#breadth_first_search #array #hash_table #math #number_theory
🟡3629.minimum-jumps-to-reach-end-via-prime-teleportation
🏷️ Tags
#breadth_first_search #array #hash_table #math #number_theory
Telegraph
minimum-jumps-to-reach-end-via-prime-teleportation
You are given an integer array nums of length n. You start at index 0, and your goal is to reach index n - 1. From any index i, you may perform one of the following operations: