#1806
Minimum Number of Operations to Reinitialize a Permutation
pupil · 565 · lc medium +29 · verified · 72.7% accepted · 327 likes · top 82%
Description
Given even integer n, start with permutation perm[i] == i. Each operation replaces perm with arr where arr[i] = perm[i/2] (even i) or arr[i] = perm[n/2 + (i-1)/2] (odd i). Return the minimum operations to restore perm to its initial state.
Code
1
2
3