2946. Matrix Similarity After Cyclic Shifts, Time complexity: O(M*N), Space complexity: O(1)
IntuitionApproachComplexity
Time complexity: O(M*N)

Space complexity: O(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(M*N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def areSimilar(self, matrix, k):
        m = len(matrix)
        n = len(matrix[0])

        def is_similar_after_cyclic_shift(matrix, k):
            nonlocal m, n
            
            for i in range(0, m):
                for j in range(0, n):
                    if (matrix[i][j] != matrix[i][(j+k) % n]):
                        return False
            
            return True

        if (k % n == 0):
            return True

        return is_similar_after_cyclic_shift(matrix, k)
```
['Python3']