You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , 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 insertionSort2( int const & _num , std::vector<int> & _arr ){ using namespace std; vector<int>::iterator it2; for(auto it1 = ++begin(_arr); it1 != end(_arr); ++it1){ it2 = it1; for(;it2 != begin(_arr); --it2){ if(*(it2 - 1) < *it2){ break; } swap(*(it2 - 1), *it2); } ::print(_arr); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , feel free to give a star :) )