Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/ByteByteGoHq/coding-interview-patterns
/ nQueens
Function
nQueens
kotlin/Backtracking/NQueens.kt:1–6 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
1
fun nQueens(n: Int): Int {
2
// In Kotlin, Global variable is anti-pattern
3
var res = mutableListOf<Int>()
4
dfs(0, mutableSetOf(), mutableSetOf(), mutableSetOf(), n, res)
5
return res[0]
6
}
7
8
fun dfs(
9
r: Int,
Callers
nothing calls this directly
Calls
1
dfs
Function · 0.70
Tested by
no test coverage detected