Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Cells with Odd Values in a Matrix

XPChallenge Points: 10
levelLevel: Easy

You are given an m × n matrix initially filled with 0’s.
You are also given a 2D array indices, where each element indices[i] = [ri, ci] represents a 0-indexed operation that increments:
• All cells in row ri
• All cells in column ci
After performing all operations, return the number of cells that contain odd values in the final matrix.

Example 1:

Input: m = 2 n = 3 indices = [[0,1],[1,1]]

Output: 6

Example 2:

Input: m = 2 n = 2 indices = [[1,1],[0,0]]

Output: 0

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result