C++ | 100% faster | 2 lines | visualization only
Just focus on position of no \'1\' by writing observing some permutations. After 1 iteration position of \'1\' is 2(which is intialization of pos) and it will a
Just focus on position of no \'1\' by writing observing some permutations. After 1 iteration position of \'1\' is 2(which is intialization of pos) and it will always be multilpied by 2. So the solution will be:\n```\nclass Solution {\npublic:\n    int pos=2,cnt=1;\n    int reinitializePermutation(int n) {\n        if(n==2) return 1;\n        while(pos!=1){\n            cnt++;\n            pos=(pos*2)%(n-1); }\n        return cnt;\n    }\n};\n```\nPlease upvote if you like.
[]