Algorithm Designa65_q3a_expressway
Expressway
fd36c50d-abcf-44f0-8d04-79e0245e84bd.cppC++
1// Loading code...Selected Submission
100 / 100
0.163s
4420 KB
Shortest PathImplementation
Time Comp.
O(V * E * (V-2)) where V is the number of nodes and E is the number of edges, due to the nested loops and relaxation process.
Space Comp.
O(V) for storing the adjacency list and the minReach vector.
Readability
4/10
"The code calculates the minimum reach from node 1 to node 2 by iteratively relaxing edges. This is a classic implementation of the Bellman-Ford algorithm for finding shortest paths, although it's applied in a specific manner and only outputs the distance to node 2 in each iteration."
History
| Attempt | Points | Time ↓ |
|---|---|---|
| Try #3 | 100 | 4/1/2025 |
| Try #2 | 100 | 4/1/2025 |
| Try #1 | 50 | 4/1/2025 |