Skip to content

1579. Remove Max Number of Edges to Keep Graph Fully Traversable #289

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to find the maximum number of edges that can be removed from an undirected graph such that the graph remains fully traversable by both Alice and Bob. The graph consists of three types of edges: type 1 (Alice only), type 2 (Bob only), and type 3 (both Alice and Bob). The solution involves using Union-Find (Disjoint Set Union, DSU) data structures to efficiently manage and check connectivity for both Alice and Bob.

Approach

  1. Problem Analysis: The problem requires us to ensure that after removing some edges, both Alice and Bob can traverse the entire graph. This means the graph must remain connected for both Alice (using type 1 and type 3 edges) and Bob (using type 2 and type 3 edge…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Jun 8, 2025
Maintainer Author

You must be logged in to vote
2 replies
@topugit
Comment options

topugit Jun 8, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim Jun 8, 2025
Maintainer Author

Answer selected by topugit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested hard Difficulty
2 participants