N-Queens

Hard
Backtracking Recursion
Place N queens on an NxN board so no two attack each other. Input: N Output: number of solutions

Constraints

See problem-specific constraints. Optimized solution required.

Examples

Example 1:
Input: 4
Output:
Example 2:
Input: 4
Output:

Hints

Consider a recursion approach.
Think about time complexity.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.