JS || Solution by Bharadwaj
Code\n\nfunction reinitializePermutation(n) {\n    let permutation = [...Array(n)].map((e, i) => i);\n    let res = 0;\n    let permToString = permutation.join(
# Code\n```\nfunction reinitializePermutation(n) {\n    let permutation = [...Array(n)].map((e, i) => i);\n    let res = 0;\n    let permToString = permutation.join(\'\');\n    while (true) {\n        let arr = Array(n);\n        for (let i = 0; i < n; i++) {\n            if (i % 2 == 1) {\n                arr[i] = permutation[n / 2 + (i - 1) / 2];\n            } else {\n                let index = i / 2;\n                arr[i] = permutation[i / 2];\n            }\n        }\n        res++;\n        if (permToString === arr.join(\'\')) {\n            break;\n        }\n        permutation = [...arr];\n    }\n\n    return res;\n};\n```
['JavaScript']