(int[][] board, int n, int col, List<String> v, List<List<String>> ans)
| 44 | } |
| 45 | |
| 46 | public void solve(int[][] board, int n, int col, List<String> v, List<List<String>> ans) { |
| 47 | if (col == n) { |
| 48 | addSol(board, n, ans); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | for (int row = 0; row < n; row++) { |
| 53 | if (isSafe(board, row, col)) { |
| 54 | board[row][col] = 1; |
| 55 | solve(board, n, col + 1, v, ans); |
| 56 | board[row][col] = 0; |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | public List<List<String>> solveNQueens(int n) { |
| 62 | int[][] board = new int[n][n]; |
no test coverage detected