java solution using hashmap
\nclass Solution {\n     public int reinitializePermutation(int n) {\n        HashMap<Integer,Integer>hashMap=new HashMap<>();\n        for (int i=1;i<=n-1;i++)
```\nclass Solution {\n     public int reinitializePermutation(int n) {\n        HashMap<Integer,Integer>hashMap=new HashMap<>();\n        for (int i=1;i<=n-1;i++)\n        {\n            if (i%2==0)\n            {\n                hashMap.put(i,i/2);\n            }\n            else\n                {\n                    int val=n/2+((i-1)/2);\n                    hashMap.put(i,val);\n                }\n        }\n        int key=1;\n        int count=0;\n        while (hashMap.get(key)!=1)\n        {\n            key=hashMap.get(key);\n            count++;\n        }\n        return count+1;\n    }\n\n}\n```
[]