Python simple list slicing
Intuition\n Describe your first thoughts on how to solve this problem. \n1. k2 = k % n;\n2. To shift a row to the left k2 times cyclically is to to move the fir
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. k2 = k % n;\n2. To shift a row to the left k2 times cyclically is to to move the first k2 cells of this row to the end of this row in the original order. Like rotating a list\n3. Use list slicing.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n * m)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n * m)\n# Code\n```\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n        m = len(mat)\n        n = len(mat[0])\n        k2 = k % n\n        \n        if k2 == 0:\n            return True\n        \n        mat2 = []\n        \n        for i in range(m):\n            row = mat[i]\n            if i % 2 == 0:\n                row2 = row[k2:] + row[:k2]\n                mat2.append(row2)\n            else:\n                row2 = row[-k2:] + row[:n - k2]\n                mat2.append(row2)\n        \n        return mat2 == mat\n                \n                \n```
['Python3']