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.
I see that you're comparing elements that are out of place and incrementing number of swaps (ret) value. But that is not neccessarily, number of minimum of swaps required.
for example,
array1: 2 5 3 1
array2: 1 2 3 5
have 3 elements out of place. but minimum number of swaps required are 2. I would appreciate you can help me understand the algorithm.
Thanks
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lily's Homework
You are viewing a single comment's thread. Return to all comments →
I see that you're comparing elements that are out of place and incrementing number of swaps (ret) value. But that is not neccessarily, number of minimum of swaps required.
for example, array1: 2 5 3 1 array2: 1 2 3 5
have 3 elements out of place. but minimum number of swaps required are 2. I would appreciate you can help me understand the algorithm.
Thanks