Leetcode Problem 1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
Leetcode Solutions
Identifying Critical and Pseudo-Critical Edges in MST using Kruskal's Algorithm
Sort the edges by weight and store the original indices.
Use Kruskal's algorithm to find the standard MST weight.
Iterate over each edge and perform two checks:
a. Ignoring the edge: Calculate the MST weight without this edge. If the weight increases or the graph becomes disconnected, mark the edge as critical.
b. Forcing the edge: Include the edge and calculate the MST weight. If the weight remains the same as the standard MST weight, mark the edge as pseudo-critical.
Return the list of critical and pseudo-critical edges.