Search
⌘K

Leetcode 2482. Difference Between Ones and Zeros in Row and Column

Given a binary m×n matrix, return a diff matrix where diff[i][j] = onesInRow(i) + onesInCol(j) - zerosInRow(i) - zerosInCol(j), i.e., the difference between the number of ones and zeros in that cell's row and column. Precompute row and column counts and combine them for each cell (expected O(mn) time, O(m+n) space; m*n ≤ 1e5).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.