Alternative Connection After Removing Direct Edge

Given an undirected simple graph with n nodes (labeled 0..n-1) and m edges, and two nodes u and v that are guaranteed to be directly connected by an edge.

Suppose that direct edge is broken...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: