You are viewing a single comment's thread. Return to all comments →
maybe , you are swapping the value in wrong way .
use this pattern : int temp= arr[arr[i]-1]; arr[arr[i]-1] =arr[i]; arr[i]= temp;
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 →
maybe , you are swapping the value in wrong way .
use this pattern : int temp= arr[arr[i]-1]; arr[arr[i]-1] =arr[i]; arr[i]= temp;