Solved LeetCode program · 632 of 1,000
#0861 · Score After Flipping Matrix
Original English source
Keep a shared rows of 0. Keep a shared columns of 0. Set rows to 3. Set columns to 4. Keep a shared grid holding 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, and 0.
For every row from 0 to rows minus 1.
The start is row times columns.
If item start of grid is 0.
For every column from 0 to columns minus 1.
The cell is start plus column. The flipped is exclusive or of item cell of grid and 1. Set item cell of grid to flipped.
Keep a shared ones of 0. Keep a shared weight of 0.
To count from column (a whole number). Set ones to 0.
For every row from 0 to rows minus 1.
The cell is row times columns plus column. If item cell of grid is 1, add 1 to ones.
To weigh from place (a whole number). Set weight to 1.
For every step from 0 to place minus 1.
Set weight to weight times 2.
The total is 0.
For every column from 0 to columns minus 1.
Count from column. The taller is ones. If rows minus ones is more than taller, set taller to rows minus ones. The place is columns minus 1 minus column. Weigh from place. Increase total by taller times weight.
Show total.
Expected stdout
39