Algorithm Designa59_q3_cycle

Cycle in Tree

9c0b0d94-3ec9-47eb-acf4-ce132b67cb0b.cppC++
1// Loading code...

Selected Submission

100 / 100
0.047s
7432 KB
BFS/DFSGraph
Time Comp.
O(V + E)
Space Comp.
O(V)
Readability
6/10

"The code performs a Depth-First Search (DFS) on a graph to calculate the distance of each node from a starting node (node 0). It detects a cycle by checking if a neighbor has already been visited and then calculates the difference in distances to determine the cycle length."

History

AttemptPoints Time
Try #61003/19/2025
Try #503/19/2025
Try #403/19/2025
Try #303/19/2025
Try #21003/19/2025
Try #16.673/19/2025