Leetcode 2608. Shortest Cycle in a Graph
Find the graph's girth: given an undirected simple graph, return the length (number of edges) of the shortest cycle or -1 if none exists. With n,m ≤ 1000, this is typically solved by repeated BFS/shortest-path searches on the unweighted graph to detect the minimal closed loop.
Asked at:
Microsoft
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early August, 2026
Senior
OA. Shortest Cycle in a graph with a twist: shortest path from every node to itself in a directed graph.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.