Skip to content

Commit 8abf179

Browse files
committed
Runtime: 1891 ms (Top 5.09%) | Memory: 280.7 MB (Top 5.05%)
1 parent 6cfbc91 commit 8abf179

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/algorithms/F/Find if Path Exists in Graph/Find if Path Exists in Graph.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
// Runtime: 1891 ms (Top 5.09%) | Memory: 280.7 MB (Top 5.05%)
12
class Solution {
23
private:
34
unordered_map<int, vector<int>> adj;
4-
unordered_map<int, bool> visited;
5-
5+
unordered_map<int, bool> visited;
6+
67
bool dfs(int node, int destination){
78
visited[node] = true;
89
for(auto neighbour:adj[node]){
@@ -19,11 +20,11 @@ class Solution {
1920
bool validPath(int n, vector<vector<int>>& edges, int source, int destination) {
2021
if(source == destination)
2122
return true;
22-
23+
2324
for(auto edge:edges){
2425
adj[edge[0]].push_back(edge[1]);
2526
adj[edge[1]].push_back(edge[0]);
2627
}
27-
return dfs(source, destination);
28+
return dfs(source, destination);
2829
}
29-
};
30+
};

0 commit comments

Comments
 (0)