N Queen is a problem in which we placing N chess Queens on a N x N chessboard in such a way that no two queens attack each other diagonally, horizontally and vertically.

Input :-

The first line contains a single integer N – the number of Queens and the size of the chessboard.

Output :-

A binary matrix which has “Q” for the blocks where queens are placed and “_” on other remaining places of chessboard.

CommentsNo comment yet.