From 237a9ae9632152baefe7518148d908a04a75f69b Mon Sep 17 00:00:00 2001 From: Tushar2001bbdu <146729736+Tushar2001bbdu@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:04:00 +0530 Subject: [PATCH] Create Solution --- Solution | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Solution diff --git a/Solution b/Solution new file mode 100644 index 0000000..f31bf3d --- /dev/null +++ b/Solution @@ -0,0 +1,84 @@ +import java.util.*; + +public class Solution +{ + public static void main(String args[]) + { + System.out.println(Solution.solveNQueens(4)); + } + public static ArrayList> solveNQueens(int n) + { + ArrayList> board=new ArrayList<>(); + for(int i =0;i sub=new ArrayList<>(); + for(int j=0;j> resultant=new ArrayList<>(); + Solution.queens(board,0,resultant); + return resultant; + } + + + + public static int queens(ArrayList> board,int row,ArrayList> resultant) + { + if(row==(board.size())) + { + ArrayList subi=new ArrayList<>(); + for(int p=0;p> board,int i,int j) + { + for(int x=0;x