Check each line with the final result And another one is simulation
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n^2)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\n    class Solution {\n        public boolean areSimilar(int[][] mat, int k) {\n            int columns = mat[0].length;\n            k = k % columns;\n\n            for (int i = 0; i < mat.length; i++) {\n                if (0 == i % 2) {\n                    for (int j = 0; j < mat[i].length; j++) {\n                        if (mat[i][j] != mat[i][(j + k) % mat[i].length]) {\n                            return false;\n                        }\n                    }\n                } else {\n                    for (int j = 0; j < mat[i].length; j++) {\n                        if (mat[i][j] != mat[i][(j + mat[i].length - k) % mat[i].length]) {\n                            return false;\n                        }\n                    }\n                }\n            }\n            return true;\n        }\n\n\n        public boolean areSimilar1(int[][] mat, int k) {\n            int[][] myInt = new int[mat.length][];\n            for (int i = 0; i < mat.length; i++) {\n                myInt[i] = mat[i].clone();\n            }\n\n            for (int i = 0; i < k; i++) {\n                for (int r = 0; r < mat.length; r++) {\n                    if (0 == r % 2) {\n                        int temp = mat[r][0];\n                        for (int c = 0; c < mat[r].length - 1; c++) {\n                            mat[r][c] = mat[r][c + 1];\n                        }\n                        mat[r][mat[r].length - 1] = temp;\n                    } else {\n                        int temp = mat[r][mat[r].length - 1];\n                        for (int c = mat[r].length - 1; c > 0; c--) {\n                            mat[r][c] = mat[r][c - 1];\n                        }\n                        mat[r][0] = temp;\n                    }\n                }\n            }\n\n            for (int i = 0; i < mat.length; i++) {\n                for (int j = 0; j < mat[i].length; j++) {\n                    if (mat[i][j] != myInt[i][j]) {\n                        return false;\n                    }\n                }\n            }\n\n            return true;\n        }\n    }\n\n```
['Java']