Once upon a time, a King had multiple queens. However, they often engaged in heated
arguments and constant quarrels. The King, wanting to restore peace in his kingdom,
decided to find a way to place the queens in a palace where they could not see each other.
Each queen had the ability to observe in up, down, left, right, and diagonally.
As the wise advisor to the King, you were tasked with arranging the n queens on nxn
chessboard in such a way that no queen could threaten another. The challenge was to
position them strategically, ensuring that no queen had a direct line of sight to any other
queen, thus preventing further conflicts among them.
This is a solution for the 4 Queen problem. The expected output
is in the form of a matrix that has ‘1’s for the blocks where
queens are placed and the empty spaces are represented by ‘0’.
There are multiple solutions to this question according to the
approach (row-wise/ column-wise).
Function Prototype:
bool royalHarmony (int**& board, int row, int column, int queens);
Note: Definition of this function should be recursive. Straight zero marks if loops are
used in function definition. Your solution will be tested on input 5 or greater than 5.