Python 3   ||   6 lines,  deque   ||   T/S: 91% / 99%
Here\'s the plan:\n- If we change the elements ofmat to deque, we can take advantage of the deque rotate method. We iterate row by row of mat, and we return Fal
Here\'s the plan:\n- If we change the elements of`mat` to `deque`, we can take advantage of the deque `rotate` method. We iterate row by row of `mat`, and we return `False` immediately if the shift results in a row that is not identical to the original row.\n\n- Also, note that the "left-shift, right-shift" distinction is a *red herring*. It makes no difference which way we shift, as long as we shift *k* units. (Think about it...)\n\n```\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n\n        deq = map(deque, mat)\n\n        for i, row in enumerate(deq):\n            \n            shifted = row.copy()\n            shifted.rotate(k)\n\n            if row != shifted: return False\n\n        return True\n```\n[https://leetcode.com/problems/matrix-similarity-after-cyclic-shifts/submissions/1295241796/](https://leetcode.com/problems/matrix-similarity-after-cyclic-shifts/submissions/1295241796/)\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ the number of elements of `mat`.
['Python3']