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.
2 parents 925c2d4 + b32af38 commit 70493f7Copy full SHA for 70493f7
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