Given an integer board_size, generate all distinct arrangements of board_size queens on a board_size x board_size grid such that no two queens are in the same row, column, or diagonal. Each arrangement should be represented as a list of strings, where Q denotes a queen and . denotes an empty cell. Return a list of all valid arrangements.
Example 1
Input: 2
Output: []
Explanation: No valid arrangement exists for board_size = 2.
Example 2
Input: 3
Output: []
Explanation: No valid arrangement exists for board_size = 3.
Example 3
Input: 5
Output: [[Q....,.Q...,...Q.,....Q,..Q..],[Q....,..Q..,....Q,.Q...,...Q.],[.Q...,...Q.,Q....,..Q..,....Q],[.Q...,....Q,..Q..,Q....,...Q.],[..Q..,Q....,...Q.,.Q...,....Q],[..Q..,....Q,.Q...,...Q.,Q....],[...Q.,Q....,..Q..,....Q,.Q...],[...Q.,.Q...,....Q,..Q..,Q....],[....Q,.Q...,...Q.,Q....,..Q..],[....Q,..Q..,Q....,.Q...,...Q.]]
Explanation: There are 10 distinct valid arrangements for board_size = 5.
Constraints
Case 1
Input: 4
Expected: [['.Q..','...Q','Q...','..Q.'],['..Q.','Q...','...Q','.Q..']]
Case 2
Input: 1
Expected: [['Q']]
Case 3
Input: 6
Expected: [['Q.....','..Q...','....Q.','.Q....','...Q..','.....Q'],['Q.....','...Q..','.Q....','.....Q','..Q...','....Q.'],['.Q....','....Q.','..Q...','Q.....','.....Q','...Q..'],['.Q....','.....Q','Q.....','...Q..','..Q...','....Q.'],['..Q...','Q.....','....Q.','.Q....','.....Q','...Q..'],['..Q...','....Q.','.Q....','...Q..','Q.....','.....Q'],['...Q..','Q.....','..Q...','.....Q','.Q....','....Q.'],['...Q..','.Q....','.....Q','Q.....','..Q...','....Q.'],['....Q.','.Q....','...Q..','Q.....','..Q...','.....Q'],['....Q.','..Q...','Q.....','.....Q','.Q....','...Q..']]