MCPcopy 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

1fun 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
8fun dfs(
9 r: Int,

Callers

nothing calls this directly

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected