You are viewing a single comment's thread. Return to all comments →
This is my submission in C++11.
int runningTime(vector<int> arr) { int i{0}, j{0}, value{0}, count{0}; for (i = 1; i < arr.size(); i++) { value = arr[i]; j = i; while (j > 0 && value < arr[j - 1]) { arr[j] = arr[j - 1]; j = j - 1; count++; } arr[j] = value; } 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 →
This is my submission in C++11.