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 :) )
void print(std::vector<int> const & _arr){ using namespace std; for(auto & num : _arr){ cout << num << " "; } cout << "\n"; } void insertionSort1( int const & _num , std::vector<int> & _arr ){ using namespace std; auto num = _arr.back(); auto itLast = --rend(_arr); for(auto it = ++rbegin(_arr); it != rend(_arr); ++it){ if(*it < num){ *(it - 1) = num; ::print(_arr); return; } *(it - 1) = *it; ::print(_arr); if(it == itLast){ *it = num; ::print(_arr); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 1
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 :) )