You are viewing a single comment's thread. Return to all comments →
a simple sol
static int minimumSwaps(int[] a) { int swap=0; for(int i=0;i<a.length;i++){ if(i+1!=a[i]){ int t=i; while(a[t]!=i+1){ t++; } int temp=a[t]; a[t]=a[i]; a[i]=temp; swap++; } } return swap; }
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 →
a simple sol