Leetcode 2204. Distance to a Cycle in Undirected Graph
Given an undirected graph, return for every vertex the shortest distance to the nearest vertex that lies on any cycle. Key idea: identify cycle vertices by iteratively pruning leaves (nodes not part of any cycle) and then perform a multi-source BFS from remaining cycle nodes to compute distances.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.