(int n)
| 11 | |
| 12 | class 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)); |