1806. Minimum Number of Operations to Reinitialize a Permutation.cpp
Code\n\nclass Solution {\npublic:\n    int reinitializePermutation(int n) {\n        vector<int> perm(n), arr(n); \n        for (int i = 0; i < n; ++i) perm[i] 
**Code**\n```\nclass Solution {\npublic:\n    int reinitializePermutation(int n) {\n        vector<int> perm(n), arr(n); \n        for (int i = 0; i < n; ++i) perm[i] = arr[i] = i;         \n        for (int k = 1; ; ++k) {\n            vector<int> tmp = arr; \n            bool flag = true; \n            for (int i = 0; i < n; ++i) {\n                if (i&1) arr[i] = tmp[n/2 + (i-1)/2]; \n                else arr[i] = tmp[i/2]; \n                if (perm[i] != arr[i]) flag = false; \n            }\n            if (flag) return k; \n        }\n        return 0; \n    }\n};\n```
['C']