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 2026-01-27
🟡3650.minimum-cost-path-with-edge-reversals
🏷️ Tags
#graph #shortest_path #heap_priority_queue
🟡3650.minimum-cost-path-with-edge-reversals
🏷️ Tags
#graph #shortest_path #heap_priority_queue
Telegraph
minimum-cost-path-with-edge-reversals
给你一个包含 n 个节点的有向带权图,节点编号从 0 到 n - 1。同时给你一个数组 edges,其中 edges[i] = [ui, vi, wi] 表示一条从节点 ui 到节点 vi 的有向边,其成本为 wi。
leetcode.com 2026-01-27
🟡3650.minimum-cost-path-with-edge-reversals
🏷️ Tags
#graph #shortest_path #heap_priority_queue
🟡3650.minimum-cost-path-with-edge-reversals
🏷️ Tags
#graph #shortest_path #heap_priority_queue
Telegraph
minimum-cost-path-with-edge-reversals
You are given a directed, weighted graph with n nodes labeled from 0 to n - 1, and an array edges where edges[i] = [ui, vi, wi] represents a directed edge from node ui to node vi with cost wi. Each node ui has a switch that can be used at most once: when…
leetcode.cn 2026-01-29
🟡2976.minimum-cost-to-convert-string-i
🏷️ Tags
#graph #array #string #shortest_path
🟡2976.minimum-cost-to-convert-string-i
🏷️ Tags
#graph #array #string #shortest_path
Telegraph
minimum-cost-to-convert-string-i
给你两个下标从 0 开始的字符串 source 和 target ,它们的长度均为 n 并且由 小写 英文字母组成。 另给你两个下标从 0 开始的字符数组 original 和 changed ,以及一个整数数组 cost ,其中 cost[i] 代表将字符 original[i] 更改为字符 changed[i] 的成本。 你从字符串 source 开始。在一次操作中,如果 存在 任意 下标 j 满足 cost[j] == z 、original[j] == x 以及 changed[j] == y…
leetcode.com 2026-01-29
🟡2976.minimum-cost-to-convert-string-i
🏷️ Tags
#graph #array #string #shortest_path
🟡2976.minimum-cost-to-convert-string-i
🏷️ Tags
#graph #array #string #shortest_path
Telegraph
minimum-cost-to-convert-string-i
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing…
leetcode.cn 2026-01-30
🔴2977.minimum-cost-to-convert-string-ii
🏷️ Tags
#graph #trie #array #string #dynamic_programming #shortest_path
🔴2977.minimum-cost-to-convert-string-ii
🏷️ Tags
#graph #trie #array #string #dynamic_programming #shortest_path
Telegraph
minimum-cost-to-convert-string-ii
给你两个下标从 0 开始的字符串 source 和 target ,它们的长度均为 n 并且由 小写 英文字母组成。 另给你两个下标从 0 开始的字符串数组 original 和 changed ,以及一个整数数组 cost ,其中 cost[i] 代表将字符串 original[i] 更改为字符串 changed[i] 的成本。 你从字符串 source 开始。在一次操作中,如果 存在 任意 下标 j 满足 cost[j] == z 、original[j] == x 以及 changed[j] ==…
leetcode.com 2026-01-30
🔴2977.minimum-cost-to-convert-string-ii
🏷️ Tags
#graph #trie #array #string #dynamic_programming #shortest_path
🔴2977.minimum-cost-to-convert-string-ii
🏷️ Tags
#graph #trie #array #string #dynamic_programming #shortest_path
Telegraph
minimum-cost-to-convert-string-ii
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters. You are also given two 0-indexed string arrays original and changed, and an integer array cost, where cost[i] represents the cost of converting…
leetcode.cn 2026-03-12
🔴3600.maximize-spanning-tree-stability-with-upgrades
🏷️ Tags
#greedy #union_find #graph #binary_search #minimum_spanning_tree
🔴3600.maximize-spanning-tree-stability-with-upgrades
🏷️ Tags
#greedy #union_find #graph #binary_search #minimum_spanning_tree
Telegraph
maximize-spanning-tree-stability-with-upgrades
给你一个整数 n,表示编号从 0 到 n - 1 的 n 个节点,以及一个 edges 列表,其中 edges[i] = [ui, vi, si, musti]:
leetcode.com 2026-03-12
🔴3600.maximize-spanning-tree-stability-with-upgrades
🏷️ Tags
#greedy #union_find #graph #binary_search #minimum_spanning_tree
🔴3600.maximize-spanning-tree-stability-with-upgrades
🏷️ Tags
#greedy #union_find #graph #binary_search #minimum_spanning_tree
Telegraph
maximize-spanning-tree-stability-with-upgrades
You are given an integer n, representing n nodes numbered from 0 to n - 1 and a list of edges, where edges[i] = [ui, vi, si, musti]:
leetcode.cn 2026-07-02
🟡3286.find-a-safe-walk-through-a-grid
🏷️ Tags
#breadth_first_search #graph #array #matrix #shortest_path #heap_priority_queue
🟡3286.find-a-safe-walk-through-a-grid
🏷️ Tags
#breadth_first_search #graph #array #matrix #shortest_path #heap_priority_queue
Telegraph
find-a-safe-walk-through-a-grid
给你一个 m x n 的二进制矩形 grid 和一个整数 health 表示你的健康值。 你开始于矩形的左上角 (0, 0) ,你的目标是矩形的右下角 (m - 1, n - 1) 。 你可以在矩形中往上下左右相邻格子移动,但前提是你的健康值始终是 正数 。 对于格子 (i, j) ,如果 grid[i][j] = 1 ,那么这个格子视为 不安全 的,会使你的健康值减少 1 。 如果你可以到达最终的格子,请你返回 true ,否则返回 false 。 注意 ,当你在最终格子的时候,你的健康值也必须为 正数 。…
leetcode.com 2026-07-02
🟡3286.find-a-safe-walk-through-a-grid
🏷️ Tags
#breadth_first_search #graph #array #matrix #shortest_path #heap_priority_queue
🟡3286.find-a-safe-walk-through-a-grid
🏷️ Tags
#breadth_first_search #graph #array #matrix #shortest_path #heap_priority_queue
Telegraph
find-a-safe-walk-through-a-grid
You are given an m x n binary matrix grid and an integer health. You start on the upper-left corner (0, 0) and would like to get to the lower-right corner (m - 1, n - 1). You can move up, down, left, or right from one cell to another adjacent cell as long…
leetcode.cn 2026-07-03
🔴3620.network-recovery-pathways
🏷️ Tags
#graph #topological_sort #array #binary_search #dynamic_programming #shortest_path #heap_priority_queue
🔴3620.network-recovery-pathways
🏷️ Tags
#graph #topological_sort #array #binary_search #dynamic_programming #shortest_path #heap_priority_queue
Telegraph
network-recovery-pathways
给你一个包含 n 个节点(编号从 0 到 n - 1)的有向无环图。图由长度为 m 的二维数组 edges 表示,其中 edges[i] = [ui, vi, costi] 表示从节点 ui 到节点 vi 的单向通信,恢复成本为 costi。 一些节点可能处于离线状态。给定一个布尔数组 online,其中 online[i] = true 表示节点 i 在线。节点 0 和 n - 1 始终在线。 从 0 到 n - 1 的路径如果满足以下条件,那么它是 有效 的:
leetcode.com 2026-07-03
🔴3620.network-recovery-pathways
🏷️ Tags
#graph #topological_sort #array #binary_search #dynamic_programming #shortest_path #heap_priority_queue
🔴3620.network-recovery-pathways
🏷️ Tags
#graph #topological_sort #array #binary_search #dynamic_programming #shortest_path #heap_priority_queue
Telegraph
network-recovery-pathways
You are given a directed acyclic graph of n nodes numbered from 0 to n − 1. This is represented by a 2D array edges of length m, where edges[i] = [ui, vi, costi] indicates a one‑way communication from node ui to node vi with a recovery cost of costi. Some…
leetcode.cn 2026-07-04
🟡2492.minimum-score-of-a-path-between-two-cities
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡2492.minimum-score-of-a-path-between-two-cities
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
minimum-score-of-a-path-between-two-cities
给你一个正整数 n ,表示总共有 n 个城市,城市从 1 到 n 编号。给你一个二维数组 roads ,其中 roads[i] = [ai, bi, distancei] 表示城市 ai 和 bi 之间有一条 双向 道路,道路距离为 distancei 。城市构成的图不一定是连通的。 两个城市之间一条路径的 分数 定义为这条路径中道路的 最小 距离。 返回城市 1 和城市 n 之间的所有路径的 最小 分数。 注意:
leetcode.com 2026-07-04
🟡2492.minimum-score-of-a-path-between-two-cities
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡2492.minimum-score-of-a-path-between-two-cities
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
minimum-score-of-a-path-between-two-cities
You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei] indicates that there is a bidirectional road between cities ai and bi with a distance equal to distancei.…
leetcode.cn 2026-07-09
🟡3532.path-existence-queries-in-a-graph-i
🏷️ Tags
#union_find #graph #array #hash_table #binary_search
🟡3532.path-existence-queries-in-a-graph-i
🏷️ Tags
#union_find #graph #array #hash_table #binary_search
Telegraph
path-existence-queries-in-a-graph-i
给你一个整数 n,表示图中的节点数量,这些节点按从 0 到 n - 1 编号。 同时给你一个长度为 n 的整数数组 nums,该数组按 非递减 顺序排序,以及一个整数 maxDiff。 如果满足 |nums[i] - nums[j]| <= maxDiff(即 nums[i] 和 nums[j] 的 绝对差 至多为 maxDiff),则节点 i 和节点 j 之间存在一条 无向边 。 此外,给你一个二维整数数组 queries。对于每个 queries[i] = [ui, vi],需要判断节点 ui 和 vi…
leetcode.com 2026-07-09
🟡3532.path-existence-queries-in-a-graph-i
🏷️ Tags
#union_find #graph #array #hash_table #binary_search
🟡3532.path-existence-queries-in-a-graph-i
🏷️ Tags
#union_find #graph #array #hash_table #binary_search
Telegraph
path-existence-queries-in-a-graph-i
You are given an integer n representing the number of nodes in a graph, labeled from 0 to n - 1. You are also given an integer array nums of length n sorted in non-decreasing order, and an integer maxDiff. An undirected edge exists between nodes i and j if…
leetcode.cn 2026-07-10
🔴3534.path-existence-queries-in-a-graph-ii
🏷️ Tags
#greedy #bit_manipulation #graph #array #two_pointers #binary_search #dynamic_programming #sorting
🔴3534.path-existence-queries-in-a-graph-ii
🏷️ Tags
#greedy #bit_manipulation #graph #array #two_pointers #binary_search #dynamic_programming #sorting
Telegraph
path-existence-queries-in-a-graph-ii
给你一个整数 n,表示图中的节点数量,这些节点按从 0 到 n - 1 编号。 同时给你一个长度为 n 的整数数组 nums,以及一个整数 maxDiff。 如果满足 |nums[i] - nums[j]| <= maxDiff(即 nums[i] 和 nums[j] 的 绝对差 至多为 maxDiff),则节点 i 和节点 j 之间存在一条 无向边 。 此外,给你一个二维整数数组 queries。对于每个 queries[i] = [ui, vi],找到节点 ui 和节点 vi 之间的 最短距离 。如果两节点之间不存在路径,则返回…
leetcode.com 2026-07-10
🔴3534.path-existence-queries-in-a-graph-ii
🏷️ Tags
#greedy #bit_manipulation #graph #array #two_pointers #binary_search #dynamic_programming #sorting
🔴3534.path-existence-queries-in-a-graph-ii
🏷️ Tags
#greedy #bit_manipulation #graph #array #two_pointers #binary_search #dynamic_programming #sorting
Telegraph
path-existence-queries-in-a-graph-ii
You are given an integer n representing the number of nodes in a graph, labeled from 0 to n - 1. You are also given an integer array nums of length n and an integer maxDiff. An undirected edge exists between nodes i and j if the absolute difference between…
leetcode.cn 2026-07-11
🟡2685.count-the-number-of-complete-components
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡2685.count-the-number-of-complete-components
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
count-the-number-of-complete-components
给你一个整数 n 。现有一个包含 n 个顶点的 无向 图,顶点按从 0 到 n - 1 编号。给你一个二维整数数组 edges 其中 edges[i] = [ai, bi] 表示顶点 ai 和 bi 之间存在一条 无向 边。 返回图中 完全连通分量 的数量。 如果在子图中任意两个顶点之间都存在路径,并且子图中没有任何一个顶点与子图外部的顶点共享边,则称其为 连通分量 。 如果连通分量中每对节点之间都存在一条边,则称其为 完全连通分量 。 示例 1: 输入:n = 6, edges = [[0,1],[0…