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.
Consider following case for split inversion :
1 3 5 6 | 2 4 7
These two are sorted sub-arrays. When you merge them 1 will need no inversions but 2 will have to invert all of 3 5 6 to reach to its appropriate place. if you think deeply enough you will realize that it is in fact the case.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Merge Sort: Counting Inversions
You are viewing a single comment's thread. Return to all comments →
Consider following case for split inversion : 1 3 5 6 | 2 4 7
These two are sorted sub-arrays. When you merge them
1
will need no inversions but 2 will have to invert all of3 5 6
to reach to its appropriate place. if you think deeply enough you will realize that it is in fact the case.