🥇 C++ | PYTHON | JAVA || Easiest Explanation || ; ] ✅
UPVOTE IF HELPFuuL\n\n# Approach\n\nFor each row perform a simple check\nrow[i] != row[(i + k) % n]\n\n# Complexity\n- Time complexity: O ( m * n ) -> Iterate t
**UPVOTE IF HELPFuuL**\n\n# Approach\n\nFor each row perform a simple check\n``` row[i] != row[(i + k) % n] ```\n\n# Complexity\n- Time complexity: O ( m * n ) -> Iterate through metrix once\n\n- Space complexity: O(1) -> No extra space Used\n\n# Code\n```Python []\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n        for l in mat:\n            n = len(l)\n            for i in range(n):\n                if l[i] != l[(i + k) % n]:\n                    return False\n        return True\n```\n```C++ []\nclass Solution {\npublic:\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        for (const auto& l : mat) {\n            int n = l.size();\n            for (int i = 0; i < n; ++i) {\n                if (l[i] != l[(i + k) % n]) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n};\n```\n```JAVA []\nclass Solution {\n    public boolean areSimilar(int[][] mat, int k) {\n        for (int[] l : mat) {\n            int n = l.length;\n            for (int i = 0; i < n; ++i) {\n                if (l[i] != l[(i + k) % n]) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n}\n```\n\n![IMG_3740.JPG](https://assets.leetcode.com/users/images/fa1ebe54-714b-4c8b-84ca-11e45c1d168c_1700971646.084058.jpeg)\n
['Python', 'C++', 'Java', 'Python3']