m × n table grid of zeros and ones.
For every cell (i, j) look at its "cross": row i together with column j. Compute:
- the number of ones in row i plus the number of ones in column j,
- minus the number of zeros in row i and minus the number of zeros in column j.
Return a table of the same size where cell (i, j) holds that value.grid=[[1, 0, 1], [0, 0, 1]] → [[1, -1, 3], [-1, -3, 1]]
For cell (0, 0): row 0 has two ones and one zero, column 0 has one one and one zero: 2 + 1 - 1 - 1 = 1. For cell (1, 2): row 1 has one one and two zeros, column 2 has two ones: 1 + 2 - 2 - 0 = 1.
grid=[[0, 0], [0, 0]] → [[-4, -4], [-4, -4]]
There are no ones at all: every row and column has two zeros, 0 + 0 - 2 - 2 = -4.
grid=[[1], [1], [0]] → [[2], [2], [0]]
grid=[[1, 0, 1], [0, 0, 1]]
[[1, -1, 3], [-1, -3, 1]]
Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.