private void totalNQueensHelper(boolean[][] board, int row, 
                                    ArrayList<Integer> solution, ArrayList<ArrayList<Integer>> result)
   {
       if (row == board.length) {
           result.add(new ArrayList<Integer>(solution));
           return;
       }

       for (int col = 0; col < board.length; col++) {
           if (checkQueen(board, row, col)) {
               board[row][col] = true;
               solution.add(col);

               totalNQueensHelper(board, row + 1, solution, result);
               
               solution.remove(solution.size()-1);
               board[row][col] = false;
           }
       }
       return;
   }