MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / solveNQueens

Method solveNQueens

Java/LeetCodeN-Queens.java:13–18  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

11
12class Solution {
13 public List<List<String>> solveNQueens(int n) {
14 List<List<String>> results = new ArrayList<>();
15 if(n ==0) return results;
16 backtrace(results, new ArrayList<String>(), 0, n, new boolean[n]);
17 return results;
18 }
19
20 public static void backtrace(List<List<String>> result, List<String> list, int level, int n, boolean[] used){
21 if(level == n) result.add(new ArrayList<String>(list));

Callers

nothing calls this directly

Calls 1

backtraceMethod · 0.95

Tested by

no test coverage detected