stringlanguage-agnosticanagram

What is an easy way to tell if a list of words are anagrams of each other?


How would you list words that are anagrams of each other?

I was asked this question when I applied for my current job.

orchestra can be rearranged into carthorse with all original letters used exactly once therefore the words are anagrams of each other.


Solution

  • Put all the letters in alphabetical order in the string (sorting algorithm) and then compare the resulting string.