Search
⌘K

Leetcode 1252. Cells with Odd Values in a Matrix

Given an m×n zero matrix and a list of indices where each (r,c) increments all cells in row r and column c, determine how many cells are odd after all operations. Key idea: track parity of row/column increments (O(m+n+indices.length) time, O(m+n) space); number of odd cells = odd_rows*(n-odd_cols) + (m-odd_rows)*odd_cols.


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.