Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to solve the N-Queens problem for a hardcoded board size (e.g., 8x8).

Hard

Problem Statement

Write a program to solve the N-Queens problem for a hardcoded board size (e.g., 8x8).

Sample Input

Board Size: 8

Sample Output

1 0 0 0 0 0 0 0 
0 0 0 0 0 0 1 0 
0 0 0 0 1 0 0 0 
0 0 0 0 0 0 0 1 
0 1 0 0 0 0 0 0 
0 0 0 1 0 0 0 0 
0 0 0 0 0 1 0 0 
0 0 1 0 0 0 0 0 

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
using System; class NQueens { static void Main() { // Solve the N-Queens problem for the given board size } }
Log in or sign up to run or submit your code.Log inSign up
Input
Board Size: 8
Expected Output
1 0 0 0 0 0 0 0 
0 0 0 0 0 0 1 0 
0 0 0 0 1 0 0 0 
0 0 0 0 0 0 0 1 
0 1 0 0 0 0 0 0 
0 0 0 1 0 0 0 0 
0 0 0 0 0 1 0 0 
0 0 1 0 0 0 0 0