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.
The flaw in your logic is that you assume that two different positions between the input array and the sorted input array are fixed with only 1 swap, when in reality it's a bit more complex than that.
Lily's Homework
You are viewing a single comment's thread. Return to all comments →
Hey, counter example here:
the expected output is 3, but with your logic:
the output is ceil(4/2) = 2
The flaw in your logic is that you assume that two different positions between the input array and the sorted input array are fixed with only 1 swap, when in reality it's a bit more complex than that.