Transform to Chessboard
HardLeetCodeConstructive Algorithms
Approach hintTry it first, then revealHide
Swaps keep the set of distinct rows, so a solvable board has exactly two complementary row types, each balanced between zeros and ones. Rows and columns are then independent: count mismatches against 0101... and respect parity.