Back to the 100
Course Practice
Hard

N-Queens

LAB

Return every valid n-queens board encoded as slash-joined rows, sorted lexicographically.

EXAMPLES

Example 1
Input
{
  "n": 4
}

Output
[
  ".Q../...Q/Q.../..Q.",
  "..Q./Q.../...Q/.Q.."
]

FUNCTION SHAPE

n: intstringArray
00:00
2 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.