leetcode.com 2023-08-19
🔴1489.find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
🏷️ Tags
#union_find #graph #minimum_spanning_tree #sorting #strongly_connected_component
🔴1489.find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
🏷️ Tags
#union_find #graph #minimum_spanning_tree #sorting #strongly_connected_component
Telegraph
find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of…
leetcode.com 2023-08-20
🔴1203.sort-items-by-groups-respecting-dependencies
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🔴1203.sort-items-by-groups-respecting-dependencies
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
sort-items-by-groups-respecting-dependencies
There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging…
leetcode.com 2023-08-23
🟡767.reorganize-string
🏷️ Tags
#greedy #hash_table #string #counting #sorting #heap_priority_queue
🟡767.reorganize-string
🏷️ Tags
#greedy #hash_table #string #counting #sorting #heap_priority_queue
Telegraph
reorganize-string
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. Example 1: Input: s = "aab" Output: "aba" Example 2: Input: s = "aaab" Output: ""…
👍1
leetcode.cn 2023-08-24
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
Telegraph
count-servers-that-communicate
这里有一幅服务器分布图,服务器的位置标识在 m * n 的整数矩阵网格 grid 中,1 表示单元格上有服务器,0 表示没有。 如果两台服务器位于同一行或者同一列,我们就认为它们之间可以进行通信。 请你统计并返回能够与至少一台其他服务器进行通信的服务器的数量。 示例 1: 输入:grid = [[1,0],[0,1]] 输出:0 解释:没有一台服务器能与其他服务器进行通信。 示例 2: 输入:grid = [[1,0],[1,1]] 输出:3 解释:所有这些服务器都至少可以与一台别的服务器进行通信。…
leetcode.cn 2023-08-25
🟡1448.count-good-nodes-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1448.count-good-nodes-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
count-good-nodes-in-binary-tree
给你一棵根为 root 的二叉树,请你返回二叉树中好节点的数目。 「好节点」X 定义为:从根到该节点 X 所经过的节点中,没有任何节点的值大于 X 的值。 示例 1: 输入:root = [3,1,4,3,null,1,5] 输出:4 解释:图中蓝色节点为好节点。 根节点 (3) 永远是个好节点。 节点 4 -> (3,4) 是路径中的最大值。 节点 5 -> (3,4,5) 是路径中的最大值。 节点 3 -> (3,1,3) 是路径中的最大值。 示例 2: 输入:root = [3,3,null,4…
leetcode.com 2023-08-26
🟡646.maximum-length-of-pair-chain
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡646.maximum-length-of-pair-chain
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
maximum-length-of-pair-chain
You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length longest chain which can be formed. You do…