MCPcopy Create free account
hub / github.com/ByteByteGoHq/coding-interview-patterns / nQueens

Method nQueens

java/Backtracking/NQueens.java:7–10  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

5 int res = 0;
6
7 public int nQueens(int n) {
8 dfs(0, new HashSet<>(), new HashSet<>(), new HashSet<>(), n);
9 return res;
10 }
11
12 private void dfs(int r, Set<Integer> diagonalsSet, Set<Integer> antiDiagonalsSet, Set<Integer> colsSet, int n) {
13 // Termination condition: If we have reached the end of the rows,

Callers

nothing calls this directly

Calls 1

dfsMethod · 0.95

Tested by

no test coverage detected