This is the basic problem of Back tracking. The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other.
Only line will take the value of N.
Output is matrix of 1 and 0.
5
1 represents queen is there and 0 represents vacant space on the board:
1 0 0 0 0
0 0 0 1 0
0 1 0 0 0
0 0 0 0 1
0 0 1 0 0