Anagram detection solution