Solutions:
The idea of the solution is similar to mine but it use two arrays to store the row and col numbers. Supposedly, this should use less memory than using java.util.Set. I improved the solution a little bit by utilizing boolean vectors: