How do you solve the N-Queens problem, and what state does the search need to track?
Place one queen per row, and for each row try every column. A column is legal if no other queen occupies that column and no other queen shares a diagonal with it. If every row can be filled, you have a solution; if a row cannot be filled, back up and try the previous row with a different column.
The state the search needs is which columns are taken and which diagonals are taken. Diagonals are identified in two ways: the row minus column value identifies one diagonal direction, and the row plus column value identifies the other. Keeping these in three sets, one for columns and one for each diagonal direction, means each legality check is a constant time membership test rather than a scan across the board.
The mechanism is that a queen on row r and column c attacks the cells that share a column, a row minus column value or a row plus column value. So the attack test becomes three set lookups. Placing the queen adds its column and its two diagonal identifiers, and removing it takes them out again, which is why the backtracking step has to undo exactly what the placement step did.
The trade-off to name is the search cost. The problem is exponential in the worst case, because the number of partial placements is enormous and only a few lead to a solution, but the pruning from the column and diagonal checks cuts it down enormously in practice. The eight queen case is solvable in milliseconds. Adding a symmetry optimisation, such as only trying the first half of the columns in the first row and mirroring the result, cuts the work further, and that kind of domain reasoning is what makes this problem a good interview topic.