Simple to understand java solution
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)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public boolean checkRow(int []arr, int k, boolean l2r){\n        int n = arr.length;\n        k = k % n;\n        \n        for(int i=0; i < n; i++){\n            if(l2r && arr[i] != arr[(i + k) % n]){\n                return false;\n            }else if(!l2r && arr[i] != arr[(n + i - k) % n]){\n                return false;\n            }\n        }\n        return true;\n    }\n    public boolean areSimilar(int[][] mat, int k) {\n        int size = mat[0].length;\n        if(k % size == 0){\n            return true;\n        }\n        boolean direction = true;\n        for(int i=0; i < mat.length; i++){\n            if(!checkRow(mat[i], k, direction)){\n                return false;\n            }\n            direction = !direction;\n        }\n        return true;\n\n    }\n}\n```
['Java']