You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )
int runningTime(std::vector<int> & _arr){ using namespace std; vector<int>::iterator it2; int shifts = 0; int num = numeric_limits<int>::min(); for(auto it1 = ++begin(_arr); it1 != end(_arr); ++it1){ it2 = it1 - 1; num = *it1; for(; num < *it2 && it2 != --begin(_arr); --it2){ *(it2 + 1) = *it2; ++shifts; } *(it2 + 1) = num; } 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 →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )