You are viewing a single comment's thread. Return to all comments →
**MY CPP EASY SOLUTION **
int runningTime(vector<int> arr) { int shifts=0,n=arr.size(); for(int i=0;i<n;i++){ int temp=i; for(int j=i-1;j>=0;j--){ if(arr[temp]<arr[j]){ swap(arr[temp],arr[j]); shifts++; temp=j; } else break; } } return shifts; }
Seems like cookies are disabled on this browser, please enable them to open this website
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
**MY CPP EASY SOLUTION **