You are viewing a single comment's thread. Return to all comments →
c++ code with simple concepts
" bool checkZero(int num1 , int num2){ if(num1 - num2 == 1){ return true; } return false; } // Complete the minimumSwaps function below. int minimumSwaps(vector arr) { int size = arr.size();
int temp =0 , swap = 0; for(int i = 0; i < size ; i++){ if(!checkZero(arr[i], i)){ for(int j = i+1; j < size ;j++){ if(checkZero(arr[j], i)){ temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; swap++; break; } } } } 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 →
c++ code with simple concepts
" bool checkZero(int num1 , int num2){ if(num1 - num2 == 1){ return true; } return false; } // Complete the minimumSwaps function below. int minimumSwaps(vector arr) { int size = arr.size();
} "