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

N-Queens Solution Count

eBay logoeBay● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the N-Queens problem. We chose to return the number of solutions and set 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 that no two queens share a row, column, or diagonal. Return the number of distinct valid placements.

Function

totalNQueens(n: int) → int

Examples

Example 1

n = 4return = 2

A four-by-four board has exactly two valid placements.

Example 2

n = 1return = 1

The only square accepts the single queen.

Constraints

  • n is 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
All eBay interview questionsSee eBay hiring insights
Saved
class Solution {
    public int totalNQueens(int n) {
        // Write your code here.
    }

}
Checking account…