C++ brute force with pointer to member function
\nclass Solution {\npublic:\n    int odd(int a,int k,int n)\n    {\n        return (a+k)%n;\n    }\n    int even(int a,int k,int n)\n    {\n        return (n+a-
```\nclass Solution {\npublic:\n    int odd(int a,int k,int n)\n    {\n        return (a+k)%n;\n    }\n    int even(int a,int k,int n)\n    {\n        return (n+a-k)%n;\n    }\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        int m = mat.size();\n        int n = mat[0].size();\n        k = k%n;\n        for(int i = 0;i<m;++i)\n        {\n            int(Solution::*cvrt)(int,int,int) =i%2?&Solution::even:&Solution::odd;  \n            for(int j = 0;j<n;++j)\n            {\n                if(mat[i][j]!=mat[i][(this->*cvrt)(j,k,n)])\n                    return false;\n            }\n        }            \n        return true;\n    }\n};\n```
['C++']