Place one queen per row. Before each placement, check the column, main diagonal (r−c), and anti-diagonal (r+c). On a dead-end row, backtrack: lift the last queen and try the next column.
junior.md for the recursion and middle.md for the bitmask speedup; professional.md proves the search visits exactly the valid partial placements.