python simple solution
Approach\nJust simulate the initially 1-indexed element.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution:\n  
# Approach\nJust simulate the initially 1-indexed element.\n\n# Complexity\n- Time complexity:\n$$O(N)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution:\n    def reinitializePermutation(self, n: int) -> int:\n        k, res = 1, 0\n        while True:\n            k <<= 1\n            res += 1\n            if k >= n:\n                k -= n - 1\n                if k == 1:\n                    break\n        return res\n```
['Python3']