You are given a 0-indexed m×n binary matrix grid. Compute a 0-indexed m×n difference matrix diff.
For every cell (i,j), the element diff[i][j] is calculated as:
Let the number of ones in the ith row be onesRow[i].
Let the number of ones in the jth column be onesCol[j].
Let the number of zeros in the ith row be zerosRow[i].
Let the number of zeros in the jth column be zerosCol[j].
diff[i][j]=onesRow[i]+onesCol[j]−zerosRow[i]−zerosCol[j]
Constraints:
m=grid.length
n=grid[i].length
1≤m,n≤105
1≤m×n≤105
grid[i][j] is either 0 or 1.