Javascript - Commented Code
js\nconst areSimilar = (mat, k) => {\n  let n = mat[0].length;\n  if (k % n == 0) return true; // back to starting pos, no change\n\n  for (const row of mat) {\
```js\nconst areSimilar = (mat, k) => {\n  let n = mat[0].length;\n  if (k % n == 0) return true; // back to starting pos, no change\n\n  for (const row of mat) {\n    let i = 0; // 1st el of original row\n    let j = k % n; // 1st el of shifted row\n\n    while (j < n) {\n      if (row[i] != row[j]) return false;\n      i++, j++;\n    }\n    j = 0; // shifted row wraps around\n    while (i < n) {\n      if (row[i] != row[j]) return false;\n      i++, j++;\n    }\n  }\n  return true;\n};\n```
['JavaScript']