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.
"Given datasets, print the number of inversions that must be swapped to sort each dataset on a new line."
This seems to imply that
every inversion requires a swap, or
not every inversion requires a swap, but we should find the minimum number of inversions that do require swaps since "number of inversions that must be swapped" <= "number of inversions"
In reality, it should simply say:
"For each dataset, print the number of inversions found in that dataset on a new line."
This problem would be much more clear without any mention of swaps.
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 →
Yes, but the problem description is misleading.
"Given datasets, print the number of inversions that must be swapped to sort each dataset on a new line."
This seems to imply that
In reality, it should simply say: "For each dataset, print the number of inversions found in that dataset on a new line."
This problem would be much more clear without any mention of swaps.