N-Queens Solution Count
Updated
Problem statement
Place n queens on an n x n chessboard so no two attack one another. Return the number of distinct valid placements.
Function
totalNQueens(n: int) → intExamples
Example 1
n = 4return = 2A four-by-four board has two solutions.
Example 2
n = 1return = 1The single square accepts one queen.
Constraints
1 <= n <= 14.
Source note: Author-written prompt excerpt retained for source fidelity.
More Optimus Information Onsite Interview questions
Similar questions at other companies
- Optimal Account BalancingAmazon · ONSITE INTERVIEW
- N-Queens Solution CounteBay · ONSITE INTERVIEWeBay 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