You are given an integer n representing the number of vertices in a connected undirected graph, labeled from n edges where edges[i] = [node1_i, node2_i] indicates a bidirectional edge between vertex node1_i and vertex node2_i.
The graph contains exactly one cycle.
Return an integer array answer of size n, where answer[i] represents the minimum distance from vertex i to any vertex that belongs to the cycle.
Constraints:
n
edges.length
edges[i].length
node1_i, node2_i n
node1_i node2_i
The graph is connected.
The graph has exactly one cycle.
There is at most one edge between any pair of vertices.
You are given an integer n representing the number of vertices in a connected undirected graph, labeled from n edges where edges[i] = [node1_i, node2_i] indicates a bidirectional edge between vertex node1_i and vertex node2_i.
The graph contains exactly one cycle.
Return an integer array answer of size n, where answer[i] represents the minimum distance from vertex i to any vertex that belongs to the cycle.
Constraints:
n
edges.length
edges[i].length
node1_i, node2_i n
node1_i node2_i
The graph is connected.
The graph has exactly one cycle.
There is at most one edge between any pair of vertices.