Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You must find distinct solutions to the 8-queen puzzle. The 8-queen puzzle involves placing 8 queens on a chess board of size (8 X 8) such that no two queens can attack each other.

Each solution contains distinct board configurations of the 8-queens’ placement where the solution are a permutation of [1, 2, 3, …., n], here the number in the ith index denotes that the ith column queen is placed in the row with that number.

For example, the permutation [1, 7, 3, 7, 5, 6, 7, 8] means the queen in the 1st column is placed in the 1st row, the queen in the 2nd column is placed in the 7th row, and so on. This permutation may or may not be a valid chessboard configuration for the 8-queen puzzle.

Note: In the output, you will have 1/0 corresponding to whether your answer is right/wrong, where 1 denotes right, and 0 denotes wrong. Also, your program will run only on one input file.

Detailed explanation

```
Time Limit: 1-sec
```