【leetcode】1252. 奇数值单元格的数目

 

int oddCells(int n, int m, int** indices, int indicesSize, int* indicesColSize){
    int i, j, cnt=0;
    int rhash[50]={0}, chash[50]={0};
    for(i=0; i<indicesSize; i++){
        rhash[indices[i][0]]++;
        chash[indices[i][1]]++;       
    }
    for(i=0; i<n; i++)
        for(j=0; j<m; j++)
            cnt += (rhash[i]+chash[j])%2;    
    return cnt;
}

 

posted @ 2020-11-29 12:18  温暖了寂寞  阅读(65)  评论(0编辑  收藏  举报