Easy to understand JavaScript solution (simulation)
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nvar reinitializePermutation = function(n) {\n    const BASE_INDEX = 1;\n    let r
# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nvar reinitializePermutation = function(n) {\n    const BASE_INDEX = 1;\n    let result = 1;\n    let index = n / 2 + (BASE_INDEX - 1) / 2;\n\n    while (index !== BASE_INDEX) {\n        index = index % 2\n            ? n / 2 + (index - 1) / 2\n            : index / 2;\n        result += 1;\n    }\n    return result;\n};\n```
['JavaScript']