Python solution, O(1) space
\nclass Solution:\n    def reinitializePermutation(self, n: int) -> int:\n        \n        i = 1\n        ans = 0\n        \n        while ans == 0 or i != 1:\
```\nclass Solution:\n    def reinitializePermutation(self, n: int) -> int:\n        \n        i = 1\n        ans = 0\n        \n        while ans == 0 or i != 1:\n            i = 2*i\n            if(i >= n-1):\n                i -= (n-1)\n            ans += 1\n        \n        return ans\n```\n\nSimulating index 1 in forward direction.\nObserve how we obtain the new array by applying the given operations to current array indices:\nThe first half indices of old array get distributed alternately in the new array starting from index 0 and last half indices of old array get distributed alternately in the new array starting from index 1.\nExample: - old array - [**0, 3, 1**, *4, 2, 5*]\nnew array - [**0**, *4*, **3**, *2*, **1**, *5*]\nSo in the code, we just multiply the index by 2 and if it becomes greater than n-1, we subtract n-1 to ensure its in the range. We just tool initial index as 1 and incremented the answer till it agains becomes 1.\n\n\n\n
[]