Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.