Skip to content

Commit 40cc455

Browse files
author
Joseph Luce
authored
Update 207_course_schedule.md
1 parent 02832b1 commit 40cc455

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

leetcode/medium/207_course_schedule.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ We will need to create a graph, as it is not provided to us, it can be an adjace
1313
For any dfs, you will need a global visited and a local visited.
1414
The global visited will tell us if we need to dfs starting at this node, this is to reduce run-time, else it will be O(N^N).
1515
The local visited is for when we are traversing the graph via. dfs and looking for cycles.
16-
I decided to use a dictionary to simplify the code, -1 will be used during the dfs, then after the dfs, changed into a 1, showing that its already visited and has no cycles.
16+
17+
I decided to use a dictionary to simplify the code, -1 will be used during the dfs, then after the dfs, changed into a 1, showing that its already visited and has no cycles. You can always use two separate visited sets but I find the code gets clunky.
1718

1819
```
1920
from collections import defaultdict

0 commit comments

Comments
 (0)