Algorithm Designa64_q4_path_sum

Path Sum

5881ac12-4eff-4263-8ed5-4e3a8716bda3.cppC++
1// Loading code...

Selected Submission

50 / 100
0.122s
1480 KB
BFS/DFSGreedy
Time Comp.
O(V * (V+E)) in the worst case, where V is the number of nodes and E is the number of edges. The outer loop iterates 8 times, and the DFS can potentially visit all nodes and edges.
Space Comp.
O(V+E) due to the adjacency list representation of the graph and the visited array.
Readability
5/10

"The code performs a Depth-First Search (DFS) to determine if a path exists from a starting node to a target cost. It employs a heuristic to prune the search space by using upper bounds on the cost. The core logic revolves around traversing the graph and checking if the accumulated cost matches the target cost. The graph is represented using an adjacency list."

History

AttemptPoints Time
Try #12504/20/2025
Try #111004/20/2025
Try #101004/20/2025
Try #91004/20/2025
Try #81004/20/2025
Try #7904/20/2025
Try #6904/20/2025
Try #5704/20/2025
Try #404/20/2025
Try #3404/20/2025
Try #2504/20/2025
Try #1504/20/2025