You are viewing a single comment's thread. Return to all comments →
unsigned int minimumSwaps(int arr_count, int* arr) { unsigned int swaps = 0; for (unsigned int i = 0; i < arr_count; i++) { if (arr[i] != (i+1)) { swap(&arr[i], &arr[arr[i]-1]); swaps++; i--; } } return swaps; }
ur right this works perfectly
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
ur right this works perfectly