You are viewing a single comment's thread. Return to all comments →
//c++ solution
int runningTime(vector<int> arr) { int count = 0; for(int i=1;i<arr.size();i++) { int x = arr[i]; for(int j=i-1;j>=0;j--) { if(arr[j] > x) { count++; arr[j+1] = arr[j]; if(j==0) arr[j] = x; } else { arr[j+1] = x; break; } } } return count; }
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 →
//c++ solution