<p>You are given an <code>m x n</code> binary matrix <code>matrix</code>.</p>

<p>You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from <code>0</code> to <code>1</code> or vice versa).</p>

<p>Return <em>the maximum number of rows that have all values equal after some number of flips</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> matrix = [[0,1],[1,1]]
<strong>Output:</strong> 1
<strong>Explanation:</strong> After flipping no values, 1 row has all values equal.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> matrix = [[0,1],[1,0]]
<strong>Output:</strong> 2
<strong>Explanation:</strong> After flipping values in the first column, both rows have equal values.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> matrix = [[0,0,0],[0,0,1],[1,1,0]]
<strong>Output:</strong> 2
<strong>Explanation:</strong> After flipping values in the first two columns, the last two rows have equal values.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>m == matrix.length</code></li>
	<li><code>n == matrix[i].length</code></li>
	<li><code>1 &lt;= m, n &lt;= 300</code></li>
	<li><code>matrix[i][j]</code> is either&nbsp;<code>0</code> or <code>1</code>.</li>
</ul>

class Solution {
    void helper(vector<int>&v1)
    {
        for(int i=0; i<v1.size(); i++)
        {
            v1[i]=~v1[i]+2;
        }
    }
    // bool check(vector<int>&v1)
    // {
    //     int a=v1[0];
    //     int count0=0;
    //     int count1=0;
    //     for(int i=1; i<v1.size(); i++)
    //     {
    //         if(v1[i]!=a)
    //         {
    //             return true;
    //         }
    //     }
    //     return false;
    // }
    // bool check(vector<int>&v1)
    // {
    //     int a=v1[0];
    //     int count0=0;
    //     int count1=0;
    //     for(int i=1; i<v1.size(); i++)
    //     {
    //         if(v1[i]==0)
    //         {
    //             count0++;
    //         }
    //         else{
    //             count1++;
    //         }
    //     }
    //     if(count1==1 || count0==1)
    //     {
    //         return 1;
    //     }
    //     return false;
    // }
public:
    int maxEqualRowsAfterFlips(vector<vector<int>>& matrix) {
        map<vector<int>, int>mymap;
        int m=matrix.size();
        int n=matrix[0].size();
        for(int i=0; i<m; i++)
        {
            vector<int>v1=matrix[i];
            // if(check(v1)==true)
            // {
            //     mymap[v1]++;
            //     helper(v1);
            //     mymap[v1]++;
            // }
            // if(check(v1)==true)
            // {
            mymap[v1]++;
            helper(v1);
            mymap[v1]++;
            // }
        }
        int ans=0;
        for(auto i=mymap.begin(); i!=mymap.end(); i++)
        {
            ans=max(ans, i->second);
        }
        return ans;
    }
};
81400