Backtracking
52. N-Queens II
Since you only need the count, there's no reason to build boards at all — just track which columns and diagonals are occupied with three bitmasks. Column j is bit j. A main diagonal is constant along…
Loading…
Since you only need the count, there's no reason to build boards at all — just track which columns and diagonals are occupied with three bitmasks. Column j is bit j. A main diagonal is constant along…
Loading…