Array
3942. Minimum Operations to Sort a Permutation
Reversal and rotate-left-by-one generate the dihedral group, and that one sentence is the whole problem. From any starting array you can reach at most 2n arrays: the n rotations of it and the n rotations of its reverse. So if nums is not a rotation of 0, 1, ..., n-1 or of n-1, ..., 1, 0, then sorted
Loading…