You are viewing a single comment's thread. Return to all comments →
He checks that both strings contain exactly the same chars. He builds an array of chars and sorts it. And then compares the resulting strings ex.
"abb" - > ['a', 'b', 'b'] -> sort -> ['a', 'b', 'b'] -> "abb" "bba" - > ['b', 'b', 'a'] -> sort -> ['a', 'b', 'b'] -> "abb" (therefore anagrams)
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
He checks that both strings contain exactly the same chars. He builds an array of chars and sorts it. And then compares the resulting strings ex.