Easy to understand | JS
Approach\nIterate over mat \'k\' times and rotate the arrays as per even or odd index.\nAfter operation compare with original array.\n Describe your approach to
# Approach\nIterate over mat \'k\' times and rotate the arrays as per even or odd index.\nAfter operation compare with original array.\n<!-- Describe your approach to solving the problem. -->\n\n# Code\n```javascript []\n/**\n * @param {number[][]} mat\n * @param {number} k\n * @return {boolean}\n */\nvar areSimilar = function(mat, k) {\n    let copyArr = JSON.stringify(mat);\n    for (let i = 0; i < k; i++) {\n        for (let j = 0; j < mat.length; j++) {\n            if (j % 2 == 0) {\n                mat[j].push(mat[j].shift());\n            } else {\n                mat[j].unshift(mat[j].pop());\n            }\n        }\n    }\n    return JSON.stringify(mat) === copyArr;\n};\n```
['JavaScript']