List comprehension, 76% speed
Code\npython3 []\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n        shift_pos = k % len(mat[0])\n        if shift_pos ==
# Code\n```python3 []\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n        shift_pos = k % len(mat[0])\n        if shift_pos == 0:\n            return True\n\n        shifted_mat = [\n            mat[r][shift_pos:] + mat[r][:shift_pos] if r % 2 == 0\n            else mat[r][-shift_pos:] + mat[r][:-shift_pos]\n            for r in range(len(mat))\n        ]\n        return mat == shifted_mat\n```
['Python3']