Easy C++ solution || Beginner-friendly approach || With explanation
Code\n\nclass Solution {\npublic:\n    int reinitializePermutation(int n) {\n        int count=0;\n        vector<int> perm(n), arr(n,0), val; \n        for(int
# Code\n```\nclass Solution {\npublic:\n    int reinitializePermutation(int n) {\n        int count=0;\n        vector<int> perm(n), arr(n,0), val; \n        for(int i=0; i<n; i++)\n            perm[i]=i;\n        val = perm;  // Save the initial value of perm to compare\n        while(val!=arr)  // We compare with arr because we update values in arr and then copy it in perm\n        {\n            if(count!=0)    perm = arr;  // We copy after iteration 1\n            for(int i=0; i<n; i++)\n                arr[i] = i%2==0 ? perm[i/2] : perm[(n/2)+(i-1)/2] ;\n            count++; \n        }\n        return count;\n    }\n};\n```
['C++']