@@ -0,0 +1,1183 @@
+package algorithms.a52_NQueensII;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class Solution %7B%0A%09%0A%09int N;%0A%09int cnt = 0;%0A%09%0A    public int totalNQueens(int n) %7B%0A        N = n;%0A        int%5B%5D%5B%5D vis = new int%5BN%5D%5BN%5D;%0A        int%5B%5D positions = new int%5BN%5D;%0A        place(0, vis, positions);%0A        return cnt;%0A    %7D%0A    %0A    public void place(int row, int%5B%5D%5B%5D vis, int%5B%5D positions) %7B%0A    %09if (row %3E= N) %7B%0A    %09%09cnt++;%0A    %09%09return;%0A    %09%7D%0A    %09for (int i = 0; i %3C N; i++) %7B%0A    %09%09if (vis%5Brow%5D%5Bi%5D == 0) %7B%0A    %09%09%09vis%5Brow%5D%5Bi%5D = 1;%0A    %09%09%09positions%5Brow%5D = i;%0A    %09%09%09List%3CPoint%3E points = new ArrayList%3C%3E();%0A    %09%09%09for (int j = 0; j %3C N; j++) %7B%0A    %09%09%09%09for (int k = 0; k %3C N; k++) %7B%0A    %09%09%09%09%09if (j == row %7C%7C k == i %7C%7C j + k == row + i %7C%7C j - k == row - i) %7B%0A    %09%09%09%09%09%09if (vis%5Bj%5D%5Bk%5D == 0) %7B%0A    %09%09%09%09%09%09%09vis%5Bj%5D%5Bk%5D = 2;%0A    %09%09%09%09%09%09%09points.add(new Point(j, k));%0A    %09%09%09%09%09%09%7D%0A    %09%09%09%09%09%7D%0A    %09%09%09%09%7D%0A    %09%09%09%7D%0A    %09%09%09place(row + 1, vis, positions);%0A    %09%09%09for (Point point : points) %7B%0A    %09%09%09%09vis%5Bpoint.x%5D%5Bpoint.y%5D = 0;%0A    %09%09%09%7D%0A    %09%09%09vis%5Brow%5D%5Bi%5D = 0;%0A    %09%09%7D%0A    %09%7D%0A    %7D%0A    %0A    class Point %7B%0A    %09int x;%0A    %09int y;%0A%09%09public Point(int x, int y) %7B%0A%09%09%09this.x = x;%0A%09%09%09this.y = y;%0A%09%09%7D%0A    %7D%0A%7D

solve 52