Skip to content

Commit c31377e

Browse files
committed
Added one solution
1 parent 13dfde9 commit c31377e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public int oddCells(int n, int m, int[][] indices) {
3+
Map<Integer, Integer> rowMap = new HashMap<>();
4+
Map<Integer, Integer> colMap = new HashMap<>();
5+
for (int[] indice : indices) {
6+
rowMap.put(indice[0], rowMap.getOrDefault(indice[0], 0) + 1);
7+
colMap.put(indice[1], colMap.getOrDefault(indice[1], 0) + 1);
8+
}
9+
int count = 0;
10+
for (int i = 0; i < n; i++) {
11+
for (int j = 0; j < m; j++) {
12+
int temp = 0;
13+
temp += rowMap.getOrDefault(i, 0);
14+
temp += colMap.getOrDefault(j, 0);
15+
count += temp % 2;
16+
}
17+
}
18+
return count;
19+
}
20+
}

0 commit comments

Comments
 (0)