Track digits seen in each row, column, and 3x3 box.
Scan the board. For each digit, compute its box index (r//3)*3 + (c//3) and check whether it already exists in that row/col/box set.
Sudoku validity is exactly the constraint “no duplicates” per row/column/box.
Track digits seen in each row, column, and 3x3 box.
Scan the board. For each digit, compute its box index (r//3)*3 + (c//3) and check whether it already exists in that row/col/box set.
Sudoku validity is exactly the constraint “no duplicates” per row/column/box.