Pattern explanation with solution [Python]
I used recursion to solve this.\n\nIf you observe, it follows a pattern:\n\n0 - 0\n1 - n/2\n2 - 1\n3 - n/2 + 1\n4 - 2\n5 - n/2 + 2\n\n\nBasically,\narr = perm[e
I used recursion to solve this.\n\nIf you observe, it follows a pattern:\n```\n0 - 0\n1 - n/2\n2 - 1\n3 - n/2 + 1\n4 - 2\n5 - n/2 + 2\n```\n\nBasically,\n`arr = perm[even indices] + perm[odd indices]`\n\n```\nclass Solution:\n    def reinitializePermutation(self, n):\n        \n        count = [0]\n        original = list(range(n))\n        \n        def recursion(perm):\n            count[0] += 1\n            arr = [] \n            for i in range(0, n, 2):\n                arr.append(perm[i])\n            for i in range(1, n, 2):\n                arr.append(perm[i])\n            \n            equals = 0\n            for i in range(n):\n                if arr[i] != original[i]:\n                    break\n                else:\n                    equals += 1\n            if equals == n:\n                return\n            recursion(arr[:])\n                    \n        recursion(original)\n        \n        return count[0]  \n```
['Recursion', 'Python', 'Python3']