FastPrepN-Queens Solution Count
Problems/N-Queens Solution Count

N-Queens Solution Count

Optimus Information logoOptimus Information● HardINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optimus Information onsite interview for interns. The report names N-Queens. We chose to return the count of solutions, and the range of board sizes.

Our version is about 90% the same as the reported question.

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) → int

Examples

Example 1

n = 4return = 2

A four-by-four board has two solutions.

Example 2

n = 1return = 1

The 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

  • 3SumONSITE INTERVIEW · Seen Oct 2026
  • Apply Overridden Integer TransformsONSITE INTERVIEW · Seen Oct 2026
  • Compute Areas Through an Abstract Shape TypeONSITE INTERVIEW · Seen Oct 2026
  • Dispatch Virtual Shipping PricesONSITE INTERVIEW · Seen Oct 2026
  • Two SumONSITE INTERVIEW · Seen Oct 2026

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
All Optimus Information interview questionsSee Optimus Information hiring insights
Saved
class Solution {
    public int totalNQueens(int n) {
        // Write your code here.
    }
}
Checking account…