You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README_EN.md
+151
Original file line number
Diff line number
Diff line change
@@ -229,4 +229,155 @@ impl Solution {
229
229
230
230
<!-- solution:end -->
231
231
232
+
<!-- solution:start -->
233
+
234
+
### Solution 2: BFS
235
+
236
+
We can use the Breadth-First Search (BFS) method, starting from node $0$, to search all other nodes. During the process, if we encounter an edge that requires a change of direction, we increment the count of direction changes.
237
+
238
+
The time complexity is $O(n)$, and the space complexity is $O(n)$. Where $n$ is the number of nodes in the problem.
0 commit comments