src/BackTracking_recursion/n_Queens.java
public static void NQueens(boolean[][] board, int row, String ans) {
		if (row == board.length) {
			System.out.println(ans);
			return;
		}

		for (int col = 0; col < board[0].length; col++) {
			
			if (isItSafeToPlaceQueen(board, row, col)) {
				board[row][col] = true;
				NQueens(board, row + 1, ans + "{" + row + "-" + col + "}");
				board[row][col] = false;
			}
		}

	}
//	print all the possible ways 4 queens can be placed in a 4x4 chess board
print all the possible ways 4 queens can be placed in a 4x4 chess board
print all the possible ways 4 queens can be placed in a 4x4 chess board
public static void NQueens(boolean[][] board, int row, String ans) {
		if (row == board.length) {
			System.out.println(ans);
			return;
		}
		for (int col = 0; col < board[0].length; col++) {
			if (isItSafeToPlaceQueen(board, row, col)) {
				board[row][col] = true;
				NQueens(board, row + 1, ans + "{" + row + "-" + col + "}");
				board[row][col] = false;
			}
		}
	}
public static void NQueens ( boolean [ ] [ ] board , int row , String ans ) { if ( row == board . length ) { System . out . println ( ans ) ; return ; } for ( int col = 0 ; col < board [ 0 ] . length ; col ++ ) { if ( isItSafeToPlaceQueen ( board , row , col ) ) { board [ row ] [ col ] = true ; NQueens ( board , row + 1 , ans + "{" + row + "-" + col + "}" ) ; board [ row ] [ col ] = false ; } } }
print all the possible ways 4 queens can be placed in a 4x4 chess board
print all the possible ways 4 queens can be placed in a 4x4 chess board