Simple python3 solution | Simulation
Complexity\n- Time complexity: O(n ^ 2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n
# Complexity\n- Time complexity: $$O(n ^ 2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n``` python3 []\nclass Solution:\n    def reinitializePermutation(self, n: int) -> int:\n        def check(arr):\n            for a, b in pairwise(arr):\n                if a + 1 != b:\n                    return None\n            return operation\n        \n        perm = list(range(n))\n        for operation in range(1, n + 1):\n            arr = [\n                perm[i // 2] if i % 2 == 0 else perm[n // 2 + (i - 1) // 2]\n                for i in range(n)\n            ]\n            \n            if (result := check(arr)) is not None:\n                return result\n\n            perm = arr\n```
['Math', 'Simulation', 'Python3']