Given an mimesnm imes nmimesn binary matrix grid, compute an mimesnm imes nmimesn difference matrix diff.
grid
diff
For every cell (i, j), the element diff[i][j] is calculated as:
i
j
diff[i][j]
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Difference Between Ones and Zeros in Row and Column
For the input [[1,0]], what is the resulting difference matrix?
[[1,0]]
[[2,0]]
[[1,-1]]
[[0,0]]
[[-1,1]]
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Implement your solution in the following coding playground.