Cells with Odd Values in a Matrix LeetCode solution in Python

1
class Solution:
2
def oddCells(self, row: int, col: int, indices: List[List[int]]) -> int:
3
rows, cols = [False] * row, [False] * col
4

5
for index in indices:
6
rows[index[0]] = not rows[index[0]]
7
cols[index[1]] = not cols[index[1]]
8

9
count = 0
10
for i in rows:
11
for j in cols:
12
count += i ^ j
13

14
return count

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0