JAVA SOLUTION
class Solution {\n    public int reinitializePermutation(int n) {\n        int p[]=new int[n];\n        int arr[]=new int[n];\n        for(int i=0;i<n;i++)\n   
class Solution {\n    public int reinitializePermutation(int n) {\n        int p[]=new int[n];\n        int arr[]=new int[n];\n        for(int i=0;i<n;i++)\n            p[i]=i;\n        int co=0;\n        while(true)\n        {\n            co++;\n            for(int i=0;i<n;i++)\n            {\n                if(i%2==0)\n                arr[i]=p[i/2];\n                else\n                arr[i]=p[n/2+(i-1)/2];\n            }\n            for(int i=0;i<n;i++)\n                p[i]=arr[i];\n            int j=0;\n            for(;j<n;j++)\n            {\n                if(p[j]==j)\n                    continue;\n                else\n                    break;\n            }\n            if(j==n)\n                return  co;\n        }\n    }\n}
[]