FastPrepMark a Queen’s Attack Board

Mark a Queen’s Attack Board

Motive logoMotive● EasyFULLTIMEPHONE SCREEN
Learn

Problem statement

Given a square board size and a zero-based queen position, return the board as strings. Use Q for the queen, X for every other cell in the queen’s row, column, or diagonals, and . for an unattacked cell.

Function

markQueenAttacks(size: int, queenRow: int, queenCol: int) → String[]

Examples

Example 1

size = 4queenRow = 0queenCol = 0return = ["QXXX","XX..","X.X.","X..X"]

Example 2

size = 3queenRow = 1queenCol = 1return = ["XXX","XQX","XXX"]

Constraints

  • 1 <= size <= 200.
  • 0 <= queenRow, queenCol < size.

More Motive problems

See Motive hiring insights
public String[] markQueenAttacks(int size, int queenRow, int queenCol) {
  // write your code here
}
size4
queenRow0
queenCol0
expected["QXXX", "XX..", "X.X.", "X..X"]
Checking account…