leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1072.cpp (461B)


0 class Solution { 1 typedef bitset<512> bs_t; 2 3 public: 4 int maxEqualRowsAfterFlips(const vector<vector<int>> &matrix) { 5 int n = matrix.size(), m = matrix[0].size(), res = 0; 6 unordered_map<bs_t, int> um; 7 for (int i = 0; i < n; i++) { 8 bs_t crnt; 9 for (int j = 0; j < m; j++) 10 crnt[j] = matrix[i][j] != matrix[i][0]; 11 res = max(res, ++um[crnt]); 12 } 13 return res; 14 } 15 };