1579. Remove Max Number of Edges to Keep Graph Fully Traversable #289
Unanswered
mah-shamim
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Alice and Bob have an undirected graph of
n
nodes and three types of edges:Given an array
edges
whereedges[i] = [typei, ui, vi]
represents a bidirectional edge of typetypei
between nodesui
andvi
, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.Return the maximum number of edges you can remove, or return
-1
if Alice and Bob cannot fully traverse the graph.Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 105
1 <= edges.length <= min(105, 3 * n * (n - 1) / 2)
edges[i].length == 3
1 <= typei <= 3
1 <= ui < vi <= n
(typei, ui, vi)
are distinct.Beta Was this translation helpful? Give feedback.
All reactions