N-Queens

Hard

📝 Description

Place n queens on nxn chessboard so no two threaten each other

Input Format

Integer n

Output Format

All distinct solutions

Constraints

1 ≤ n ≤ 9

🔍 Sample Input

4
            

✅ Sample Output

[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run