Solution: N-Queens II
Let's solve the N-Queens II problem using the Backtracking pattern.
Statement
Given an integer, n
, representing the size of an n x n
chessboard, return the number of distinct ways to place n
queens so that no two queens attack each other. A queen can attack another queen if they are in the same row, column, or diagonal.
Constraints:
n
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.