Solved LeetCode program · 818 of 1,000
#1072 · Flip Columns For Maximum Number of Equal Rows
Original English source
The grid is a list of 0, 1, 1, and 0. The rows is 2. The columns is 2. The keys is an empty list of whole numbers.
For every row from 0 to rows minus 1.
The anchor is item (row times columns) of grid. The key is 0.
For every column from 0 to columns minus 1.
The cell is item (row times columns plus column) of grid. The bit is exclusive or of cell and anchor. Set key to key times 3 plus bit. Place key into keys.
The best is 0.
For each key in keys.
The count is 0.
For each other in keys.
If other is key, add 1 to count. If count is more than best, set best to count.
Show best.
Expected stdout
2