-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1252.cpp
More file actions
32 lines (32 loc) · 751 Bytes
/
1252.cpp
File metadata and controls
32 lines (32 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Solution {
public:
int oddCells(int n, int m, vector<vector<int>>& indices) {
int A[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
A[i][j]=0;
}
}
int k=0;
while(k<indices.size()){
int y=indices[k][0];
int x=indices[k][1];
for(int j=0;j<m;j++){
A[y][j]+=1;
}
for(int jj=0;jj<n;jj++){
A[jj][x]+=1;
}
k++;
}
int count=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(A[i][j]%2!=0){
count++;
}
}
}
return count;
}
};