Graph
LeetCode 1306: Jump Game III
·2 mins
LeetCode
Medium
Bfs
Dfs
Graph
Array
LeetCode 1306 note: indices are nodes and the two jumps are edges; BFS or DFS decides whether a zero is reachable
LeetCode 3619: Count Islands With Total Value Divisible by K
·2 mins
LeetCode
Medium
Dfs
Bfs
Matrix
Graph
LeetCode 3619 note: flood fill each island and sum its values; with up to 10^5 cells, iterate to avoid deep recursion
LeetCode 3613: Minimize Maximum Component Cost
·2 mins
LeetCode
Medium
Union-Find
Graph
Sorting
Binary-Search
LeetCode 3613 note: add edges from light to heavy; the weight when exactly k components remain is the answer, and 0 when n <= k
LeetCode 3608: Minimum Time for K Connected Components
·2 mins
LeetCode
Medium
Union-Find
Graph
Sorting
Binary-Search
LeetCode 3608 note: add edges back from the largest time; the time of the first edge that drops the component count below k is the answer
LeetCode 3607: Power Grid Maintenance
·3 mins
LeetCode
Medium
Heap
Union-Find
Graph
Lazy-Deletion
LeetCode 3607 note: Union-Find groups, one min-heap per group, and lazy deletion for offline stations
LeetCode 3493: Properties Graph
·2 mins
LeetCode
Medium
Graph
Dfs
Union-Find
Hash-Map
LeetCode 3493 note: convert each row to a set, compare intersection sizes pairwise to add edges, then count components
LeetCode 1791: Find Center of Star Graph
·1 min
LeetCode
Easy
Graph
LeetCode 1791 note: the center lies on every edge, so the common endpoint of the first two edges is the answer
LeetCode 133: Clone Graph
·1 min
LeetCode
Medium
Hash-Table
Depth-First-Search
Breadth-First-Search
Graph
LeetCode 133 note: during DFS map each old node to its copy and return the existing copy when revisited, avoiding infinite recursion; an empty graph returns None
LeetCode 997: Find the Town Judge
·2 mins
LeetCode
Easy
Array
Hash-Table
Graph
LeetCode 997 note: the judge is trusted by the other n - 1 people and trusts nobody, so in-degree minus out-degree equals n - 1