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.
Very nice explanation but I have one doubt what if the array have duplicate elements like: 7 3 0 4 1 0 5 0
because now "0" is present at index [2], [5], [7] , so in the first swap at which index we are going to swap "7" with.
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 →
Very nice explanation but I have one doubt what if the array have duplicate elements like: 7 3 0 4 1 0 5 0 because now "0" is present at index [2], [5], [7] , so in the first swap at which index we are going to swap "7" with.