1072. 按列翻转得到最大值等行数

class Solution {
public:
int maxEqualRowsAfterFlips(vector& matrix) {
int row = matrix.size(), col = matrix[0].size();
unordered_map mp;
for (int i = 0; i < row; i++) {
string str = string(col, ‘0’);
for (int j = 0; j < col; j++) {
str[j] = ‘0’ + (matrix[i][j] ^ matrix[i][0]);
}
mp[str]++;
}

    int res = 0;
    for (auto &[k,v] : mp) {
        res = max(res, v);
    }
    
    return res;
}

};

你可能感兴趣的:(#,《leetcode的刷题周记》,算法,c++,数据结构)