BRUTE FORCE
CODE:\n\nclass Solution {\n    public int reinitializePermutation(int n) {\n        int[] perm=new int[n];\n        int[] nums=new int[n];\n        for(int i=0;
CODE:\n```\nclass Solution {\n    public int reinitializePermutation(int n) {\n        int[] perm=new int[n];\n        int[] nums=new int[n];\n        for(int i=0;i<n;i++){\n            perm[i]=i;\n            nums[i]=i;\n        }\n        int operation=1;\n        while(true){\n            int[] arr=performOperation(perm,n);\n            if(isEqualToInitial(arr,nums)) return operation;\n            perm=arr;\n            operation++;\n        }\n     \n    }\n    \n    private boolean isEqualToInitial(int[] arr1,int[] arr2){\n        for(int i=0;i<arr1.length;i++){\n            if(arr1[i]!=arr2[i]) return false;;\n        }\n        return true;\n    }\n    \n    private  int[] performOperation(int[] perm,int n){\n          int[] arr=new int[n];\n        for(int i=0;i<perm.length;i++){\n            if(i%2==0){\n              arr[i]=perm[i/2];\n            }else{\n                arr[i]=perm[n/2 + (i-1)/2];\n            }\n        }\n        return arr;\n    }\n}\n```\njust follow the steps as per question.\n\nPlease **UPVOTE** if found it helpful and feel free to reach out to me or comment down if you have any doubt.
['Java']