Skip to content

Commit

Permalink
Merge pull request #32 from kounkou/updated-topological-sort
Browse files Browse the repository at this point in the history
(chore) Update topological code answer
  • Loading branch information
kounkou authored Oct 25, 2024
2 parents 211aab0 + da73a0c commit 35b5565
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions logic/topological-sorting/topological-sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var question = [
answerCpp: `void dfs(int node, map<int, bool>& visited, stack<int>& stk, vector<int> graph[]) {
visited[node] = true;
for (int i : graph[node]) {
if (visited[i]) continue;
dfs(i, visited, stk, graph);
for (int nei : graph[node]) {
if (visited[nei]) continue;
dfs(nei, visited, stk, graph);
}
stk.push(node);
Expand All @@ -35,9 +35,9 @@ void topoSortGraph(vector<int> nodes, vector<int> graph[]) {
answerGo: `func dfs(v int, visited []bool, stk *[]int, graph [][]int) {
visited[v] = true
for _, i := range graph[v] {
if !visited[i] {
dfs(i, visited, stk, graph)
for _, nei := range graph[v] {
if !visited[nei] {
dfs(nei, visited, stk, graph)
}
}
Expand Down

0 comments on commit 35b5565

Please sign in to comment.