Persistent Systems | On Campus OA 2022 | Backtracking, Recursive Search and Constraint Optimization in Chessboard Placement Problem
Question · Posted Jun 2026
Problem Statement The N-Queens Problem requires placing n queens on an n × n chessboard such that no two queens attack each other. A queen can attack another queen if they share: The same row The same column The same diagonal Return all distinct solutions. Each solution should be represented as a board configuration where: 'Q' represents a queen '.' represents an empty cell Example 1 Input: n = 4 Output: [ [".Q..", "...Q", "Q...", "..Q."], ["..Q.", ...
The full answer & interview discussion are available to premium members.
Log in Create a free account