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.
Why should right_half start from mid and not mid+1? I had a similar implementation but with it starting from mid+1 and I got all the sample test cases wrong. My thinking was that if you start from mid the last element of left_half and first of right_half would be the same, which wouldn't make sense.
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 →
Why should right_half start from mid and not mid+1? I had a similar implementation but with it starting from mid+1 and I got all the sample test cases wrong. My thinking was that if you start from mid the last element of left_half and first of right_half would be the same, which wouldn't make sense.