Golang O(N ^ 2) solution with index comparison (98.89% Runtime)
Intuition\n Describe your first thoughts on how to solve this problem. \n\nReduce k to "k % len(column)". Then compare elements with shifted indexes\n\n# Approa
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/2fc247e8-bed6-4e88-a9b2-1f7fce770672_1701247004.233802.png)\nReduce k to "k % len(column)". Then compare elements with shifted indexes\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- K can be larger than column length. Thus change k to k % len(column)\n- Define two column indexes:\n  - Index j will be normal index starts with 0\n  - Index "idx" means shifted index based on row\'s index\n- Perform elementwise comparison between two indexes:\n  - If row index is even (left shift), "idx" starts from k \n  - If row index is odd (right shift), "idx" starts from n - k\n\n# Complexity\n- Time complexity: O(N ^ 2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\nIf this solution is similar to yours or helpful, upvote me if you don\'t mind\n```\nfunc areSimilar(mat [][]int, k int) bool {\n    n := len(mat[0])\n    k = k % n\n    idx := k\n\n    for i, row := range(mat) {\n        if i % 2 == 1 {\n            idx = n - k\n        } else {\n            idx = k\n        }\n        for j := 0; j < n; j++ {\n            if row[j] != row[idx % n] {\n                return false\n            }\n            idx += 1\n        }\n    }\n\n    return true\n}\n```
['Array', 'Matrix', 'Go']