100% Faster | Easy | O(1) space
```\nclass Solution {\n    public boolean areSimilar(int[][] mat, int k) {\n        int col = mat[0].length;\n        k = k % col;\n        if(k == 0)\n        
```\nclass Solution {\n    public boolean areSimilar(int[][] mat, int k) {\n        int col = mat[0].length;\n        k = k % col;\n        if(k == 0)\n            return true;\n        \n        for(int i=0; i<mat.length; i++){\n            for(int j=0; j<col; j++){\n                int c = (i%2 == 0) ? ((col + (j - k)) % col) : ((j + k) % col);\n                if(mat[i][j] != mat[i][c])\n                    return false;\n            }\n        }\n        \n        return true;\n    }\n}
['Java']