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.
staticintminimumSwaps1(int[]arr){intcurrentMin=1;intcurrentInd=0;intminSwapsCount=0;while(currentMin!=arr.length){for(inti=currentInd;i<arr.length;i++){if(arr[i]==currentMin){if(i==currentInd){//It is already sorted..currentInd++;currentMin++;break;}swap(arr,i,currentInd);minSwapsCount++;currentInd++;currentMin++;}}}returnminSwapsCount;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
Don't break my eyes