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 makingAnagrams( std::string _s1 , std::string _s2 ){ size_t minDeletions = 0; std::sort(_s1.begin(), _s1.end()); std::sort(_s2.begin(), _s2.end()); auto it1 = _s1.cbegin(); auto it2 = _s2.cbegin(); while(it1 != _s1.cend() && it2 != _s2.cend()){ if(*it1 < *it2){ ++minDeletions; ++it1; }else if(*it1 > *it2){ ++minDeletions; ++it2; }else{ ++it1; ++it2; } } return minDeletions += it1 == _s1.cend() ? std::distance(it2, _s2.cend()) : std::distance(it1, _s1.cend()) ; }
Seems like cookies are disabled on this browser, please enable them to open this website
Making Anagrams
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:) )