Answer: MFINE Hiring | Interview Question | Off-Campus OA (2022)

Answer · Posted Jun 2026

Approach First count: Number of ones in each row. Number of ones in each column. Since: zerosRow[i] = n - rowOnes[i] zerosCol[j] = m - colOnes[j] Substituting into the formula: diff[i][j] = rowOnes[i] + colOnes[j] - (n - rowOnes[i]) - (m - colOnes[j]) = 2 * rowOnes[i] + 2 * colOnes[j] - m - n This avoids explicitly counting zeros. Strategy Traverse matrix once to count row ones and column ones. Traverse again to compute each answer using the simplified ...

The full answer & interview discussion are available to premium members.

Log in Create a free account