Browse and switch challenges
N-Queens

Return the number of distinct ways to place N queens on an N×N board so that none attack each other.

Important

  • -Queens cannot share rows, columns, or diagonals.
Signature
Constraints
  • -1 ≤ N ≤ 14
Examples
    System prompt
    0 tokens
    Read-only
    // Waiting for generated code…
    // Your output will appear here as soon as the model returns JavaScript.
    // It must define function nqueens(…).
    // Tip: write a prompt on the left and click "Generate code" .
    0 tokens
    Submission #1
    0tokens(0/0)
    Leaderboard
    Loading leaderboard...