package algorithms.a51_NQueens;

import java.util.List;

public class Solution {
	int N;
	
    public List<List<String>> solveNQueens(int n) {
    	N = n;
        int[] positions = new int[n];
        int[][] vis = new int[n][n];
        
    }
    
    public void place(int row, int[][] vis, int[] positions) {
    	for (int i = 0; i < N; i++) {
    		if (vis[row][i] == 0) {
    			vis[row][i] = 1;
    			positions[row] = i;
    			for (int j = 0; j < N; j++) {
    				for (int k = 0; k < N; k++) {
    					if (j == row || k == i || j + k == row + i || j - k == row - i) {
    						if (vis[j][k] == 0) {
    							
    						}
    					}
    				}
    			}
    		}
    	}
    }
    
}
@@ -26,16 +26,44 @@
 ueens;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -110,16 +110,61 @@
 %09int N;%0A
+%09List%3CList%3CString%3E%3E ans = new ArrayList%3C%3E();%0A
 %09%0A    pu
@@ -308,82 +308,596 @@
     
-%0A    %7D%0A    %0A    public void place(int row, int%5B%5D%5B%5D vis, int%5B%5D positions) %7B
+place(0, vis, positions);%0A        return ans;%0A    %7D%0A    %0A    public List%3CString%3E drawGraph(int%5B%5D positions) %7B%0A    %09char%5B%5D%5B%5D graph = new char%5BN%5D%5BN%5D;%0A    %09List%3CString%3E res = new ArrayList%3C%3E();%0A    %09for (int i = 0; i %3C N; i++) %7B%0A    %09%09for (int j = 0; j %3C N; j++) %7B%0A    %09%09%09if (positions%5Bi%5D == j) %7B%0A    %09%09%09%09graph%5Bi%5D%5Bj%5D = 'Q';%0A    %09%09%09%7D else %7B%0A%09%09%09%09%09graph%5Bi%5D%5Bj%5D = '.';%0A%09%09%09%09%7D%0A    %09%09%7D%0A    %09%09res.add(new String(graph%5Bi%5D));%0A    %09%7D%0A    %09return res;%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%09ans.add(drawGraph(positions));%0A    %09%09return;%0A    %09%7D
 %0A   
@@ -1009,16 +1009,63 @@
 w%5D = i;%0A
+    %09%09%09List%3CPoint%3E points = new ArrayList%3C%3E();%0A
     %09%09%09f
@@ -1253,63 +1253,378 @@
 %09%09%09%09
-%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%7D%0A    
+vis%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 

solve 51