We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intsherlockAndAnagrams(stringa){// Complete this functionintana=0;intdiff=1;for(inti=0;i<a.size()-1;i++){vector<string>substrings(0);for(intj=0;j<a.size()-diff+1;j++){substrings.push_back(a.substr(j,diff));}for(intj=0;j<substrings.size();j++){sort(substrings[j].begin(),substrings[j].end());}for(intx=0;x<substrings.size();x++){for(inty=x+1;y<substrings.size();y++){if(substrings[x]==substrings[y]){ana++;}}}diff++;}returnana;}
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
C++: