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 anagram(std::string _str){ auto const sz = _str.size(); if(sz % 2){ return -1; } auto const halfSz = sz / 2; std::sort(_str.begin(), _str.begin() + halfSz); std::sort(_str.begin() + halfSz, _str.end()); std::string diff(halfSz, '_'); return std::distance( diff.begin() , std::set_difference( _str.cbegin() , _str.cbegin() + halfSz , _str.cbegin() + halfSz , _str.cend() , diff.begin() ) ); }
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
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 :) )