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
| Attempt | Points | Time ↓ |
|---|---|---|
| Try #6 | 100 | 3/19/2025 |
| Try #5 | 0 | 3/19/2025 |
| Try #4 | 0 | 3/19/2025 |
| Try #3 | 0 | 3/19/2025 |
| Try #2 | 100 | 3/19/2025 |
| Try #1 | 6.67 | 3/19/2025 |