Skip to content
CampusEduX

N Queens

Hardjavapythonccppjavascript

Count the number of distinct ways to place N queens on an N x N chessboard so that no two queens attack each other (no two share a row, column or diagonal).

Input Format

A single line containing the integer N.

Output Format

Print the number of valid arrangements.

Related Problems

  • Sudoku Solver
    Hard · java, python, c, cpp, javascript
    Solve Problem
  • Factorial Using Recursion
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Fibonacci Number
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...