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.
It's essentially a reverse insertion sort. You just keep looping through the array doing a single swap until it's sorted. Count how many times you had to make a swap to get it sorted.
Break if the value of any element is more than two higher than its original position.
New Year Chaos
You are viewing a single comment's thread. Return to all comments →
Javascript
It's essentially a reverse insertion sort. You just keep looping through the array doing a single swap until it's sorted. Count how many times you had to make a swap to get it sorted. Break if the value of any element is more than two higher than its original position.