We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
here what I am doing I am counting total number of inversion pairs .
If they are Even then it is possible to get sorted array after rotating triples. since after rotating or transposing the array the total number of inversions will either increase by 2 or decrease by 2 so if total number of inversions are even then eventually after rotating after some point you'll get inversions 0 which implies that array is sorted but in case you have total inversions odd you can never have 0 inversions after rotating or transposing
Larry's Array
You are viewing a single comment's thread. Return to all comments →
here what I am doing I am counting total number of inversion pairs . If they are Even then it is possible to get sorted array after rotating triples. since after rotating or transposing the array the total number of inversions will either increase by 2 or decrease by 2 so if total number of inversions are even then eventually after rotating after some point you'll get inversions 0 which implies that array is sorted but in case you have total inversions odd you can never have 0 inversions after rotating or transposing