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::string biggerIsGreater(std::string & str){ using namespace std; using Char_t = remove_reference<decltype(str)>::type::value_type; auto max = rend(str); for(auto it1 = rbegin(str) + 1; it1 != rend(str); ++it1){ if(*it1 < *(it1 - 1)){ for(auto it2 = rbegin(str); it2 != it1; ++it2){ if(*it1 < *it2){ swap(*it1, *it2); sort(rbegin(str), it1, greater<Char_t>()); return str; } } } } return "no answer"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Bigger is Greater
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: ) )