Using Basic Formula | Java Solution
Intuitionnew index for Even row after shift
newC => (j - k%n +n) %nnew index for Odd row after shifting
newC => (j+k)%nAnd after  that check the both array or y
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

new index for Even row after shift 
newC => (j - k%n +n) %n

new index for Odd row after shifting
newC => (j+k)%n

And after  that check the both array or you just check the new index with old one 

mat[i][newC] != mat[i][j];
return false;

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

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

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

# Code
```java []
class Solution {
    public boolean areSimilar(int[][] mat, int k) {
        int[][] ans = new int[mat.length][mat[0].length];
        int m = mat.length;
        int n = mat[0].length;

        for(int i=0; i<mat.length; i++){
            for(int j=0; j<mat[0].length; j++){
                if(i%2==0){
                    int newC = (j - k %n  + n)%n;
                    ans[i][newC] = mat[i][j];
                }else{
                    int newC = (j+k)%n;
                    ans[i][newC] = mat[i][j];
                }
            }
        }

        for(int i=0;i<mat.length;i++){
            for(int j=0;j<mat[0].length;j++){
                if(ans[i][j] != mat[i][j]){
                    return false;
                }
            }
        }
        return true;
    }
}
```
['Java']