N-Queens II

Hard · Backtracking · about 20 minutes

Asked at Google, Amazon, Microsoft, Meta.

Return the number of ways to place n queens on an n × n board so that no two attack each other.

Related guides