Brute force using series of for loops
\n# Approach\n Describe your approach to solving the problem. \n1. Make a copy of the original array\n2. Make k shifts based on index \n3. Compare the copy with
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Make a copy of the original array\n2. Make k shifts based on index \n3. Compare the copy with the shifted array\n\n# Code\n```\nclass Solution {\n    public boolean areSimilar(int[][] mat, int k) {\n        int[][] copy = new int[mat.length][mat[0].length];\n\n        // Made a copy of original array\n        for(int i = 0; i < mat.length; i++) {\n            for(int j = 0; j < mat[0].length; j++) {\n                copy[i][j] = mat[i][j];\n            }    \n        } \n\n        // shift the array\n        mat = shifted(mat, k);\n        \n        // Checks each index of both arrays\n        for(int i = 0; i < mat.length; i++) {\n            for(int j = 0; j < mat[0].length; j++) {\n                if(copy[i][j] != mat[i][j]) {\n                    return false; \n                }\n            }\n        } \n        return true;\n    }\n\n    // This private method returns the shifted int[][] (matrix)\n    // It takes in an int[][] and int k and shifts each\n    // array in the matrix based on the index \n    private int[][] shifted(int[][] mat, int k) {\n        for(int h = 0; h < k; h++) { // shifts k times\n            for(int i = 0; i < mat.length; i++) {\n                if(i % 2 == 0) { // if even index, shift left\n                    int temp = mat[i][0]; // hold first index\n                    for(int j = 0; j < mat[0].length - 1; j++) {\n                        mat[i][j] = mat[i][j + 1]; // shifts left\n                    }\n                    mat[i][mat[0].length - 1] = temp;\n                } else { // if odd, shift right\n                    int temp = mat[i][mat[i].length - 1]; // hold last index\n                    for(int j = mat[0].length - 2; j >= 0 ; j--) {\n                        mat[i][j + 1] = mat[i][j]; // shift right\n                    }\n                    mat[i][0] = temp; \n                }\n            }    \n        }\n        return mat;\n    }\n}\n```
['Array', 'Java']