Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.