c++ easy solution..
\nclass Solution {\npublic:\n    int reinitializePermutation(int n) {\n        vector<int> perm(n);\n        for(int i = 0; i < n; ++i) perm[i] = i;\n        in
```\nclass Solution {\npublic:\n    int reinitializePermutation(int n) {\n        vector<int> perm(n);\n        for(int i = 0; i < n; ++i) perm[i] = i;\n        int ret = 0;\n        vector<int> arr(n);\n         //int ret = 0;\n        while(true){\n        for(int i = 0;i<n;i++){\n              if(i%2==0){\n                  arr[i] = perm[i/2];\n              }\n            else{\n                arr[i] = perm[n/2 + (i-1)/2];\n            }\n        }\n            ret++;\n            int i = 0;\n            for(i=0; i < n; ++i) {\n                if(arr[i] != i) break;\n            }\n            if(i == n) return ret;\n             perm = arr;\n        }\n        return 0;\n    }\n};\n```
[]