Hi,
I was wondering why the solution to this problem seems so complicated. Why not just check all elements in one pass, since we have 9 rows, 9 columns and 9 3x3 grids, we need 27 bits per digit (1-9), which would be sufficed to keep in array of 9 integers. Then as we iterate through the board we check 3 flags for given digit (1 for row, 1 for column and 1 for 3x3 grid) and if any set then the board is invalid. Otherwise we set these 3 flags for a given digit. This could be generalized to nxn board if necessary, just need more storage for the array of bit flags.
Thanks,
Yev