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 :) )
std::vector<int> largestPermutation( int _swaps , std::vector<int> _arr ){ using namespace std; size_t dst = 0; for(auto it = begin(_arr); it != end(_arr) && _swaps != 0; ++it){ dst = distance(it, end(_arr)); if(dst == *it){ continue; } swap(*it, *(find( it + 1, end(_arr), dst))); --_swaps; } return _arr; }
Seems like cookies are disabled on this browser, please enable them to open this website
Largest Permutation
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 :) )