private int find(ArrayList<Integer> current, HashMap<Integer, Boolean> diagonal1,
                     HashMap<Integer, Boolean> diagonal2, int n) {
        int result = 0;
        if (current.size() == n) {
            return 1;
        } else {
            //find available column
            int row = current.size();
            for (Integer col : available(current, n)) {

                if ((diagonal1.get(row + col) == null || diagonal1.get(row + col) == false) && (diagonal2.get(row - col) == null || diagonal2.get(row - col) == false)) {
                    current.add(col);
                    diagonal1.put(row + col, true);
                    diagonal2.put(row - col, true);
                    result += find(current, diagonal1, diagonal2, n);
                    current.remove(current.size() - 1);
                    diagonal1.put(row + col, false);
                    diagonal2.put(row - col, false);
                }

            }
        }
        return result;
    }