N-Queens Solution Count
Updated
Problem statement
Place n queens on an n x n chessboard so that no two queens share a row, column, or diagonal. Return the number of distinct valid placements.
Function
totalNQueens(n: int) → intExamples
Example 1
n = 4return = 2A four-by-four board has exactly two valid placements.
Example 2
n = 1return = 1The only square accepts the single queen.
Constraints
nis between 1 and 14.
Source note: Author-written prompt excerpt retained for source fidelity.
More eBay interview questions
- Count Staircases with Strictly Increasing StepsONSITE INTERVIEW · Seen Oct 2026
- Hierarchical Permission CheckONSITE INTERVIEW · Seen Oct 2026
- Matrix MultiplicationONSITE INTERVIEW · Seen Oct 2026
- Gas StationONSITE INTERVIEW · Seen Oct 2026
- Onion-Peel Layers of a Binary TreeONSITE INTERVIEW · Seen Oct 2026
- Container With Most WaterONSITE INTERVIEW · Seen Aug 2026
- Daily TemperaturesONSITE INTERVIEW · Seen Aug 2026
- Meeting Rooms IIPHONE SCREEN · Seen Oct 2026
- Construct a Binary Tree from Preorder and InorderPHONE SCREEN · Seen Oct 2026
- Maximum Size Subarray Sum Equals KPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- N-Queens Solution CountOptimus Information · ONSITE INTERVIEWOptimus Information interview questions
- Count and Score Distinct Hat AssignmentsRoblox · ONSITE INTERVIEWRoblox interview questions
- Maximum Currency Conversion Along a Simple PathRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- Maximize Valid TrainsBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
- Count Eight-Neighbor Unlock PatternsGoogle · ONSITE INTERVIEWGoogle interview questions
- Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
- Generate All Valid Word AbbreviationsSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Beautiful ArrangementMathWorks · ONSITE INTERVIEWMathWorks interview questions
- SubsetsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Choose the Next Minesweeper ActionRunloop · PHONE SCREEN