class Solution {
public int oddCells(int m, int n, int[][] indices) {
int[][] arr = new int[m][n];
for (int[] indice: indices) {
for (int j = 0; j < n; j++) arr[indice[0]][j]++;
for (int i = 0; i < m; i++) arr[i][indice[1]]++;
}
int ans = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (arr[i][j] % 2 == 1) ans++;
}
}
return ans;
}
}
class Solution {
public int oddCells(int m, int n, int[][] indices) {
int[] row = new int[m], col = new int[n];
for(int[] indice: indices) {
row[indice[0]]++;
col[indice[1]]++;
}
/** 对于point[i][j], 其数值等于row[i]+col[j] */
int ans = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if ((row[i]+col[j]) % 2 == 1) ans++;
}
}
return ans;
}
}