We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b82c623 commit b32af38Copy full SHA for b32af38
core-kotlin-modules/core-kotlin-10/src/main/kotlin/com/baeldung/bfs/Bfs.kt
@@ -1,7 +1,7 @@
1
package com.baeldung.bfs
2
3
-fun bfs(graph: Map<Int, List<Int>>, start: Int): List<Int> {
4
- val visited = mutableListOf<Int>()
+fun bfs(graph: Map<Int, List<Int>>, start: Int): Set<Int> {
+ val visited = mutableSetOf<Int>()
5
val queue = ArrayDeque<Int>()
6
queue.add(start)
7
while (queue.isNotEmpty()) {
0 commit comments