[LeetCode] Distance to a Cycle in Undirected Graph

1 · · April 6, 2022, 7:04 a.m.
2204. Distance to a Cycle in Undirected Graph You are given a positive integer n representing the number of nodes in a connected undirected graph containing exactly one cycle. The nodes are numbered from 0 to n - 1 (inclusive). You are also given a 2D integer array edges, where edges[i] = [node1i, node2i] denotes that there is a bidirectional edge connecting node1i and node2i in the graph. The distance between two nodes a and b is defined to be the minimum number of edges that are needed to go ...