#### Topic: Optimization of search of anagrams

Received recently curious job for interview. Here the job text: Anagrams are defined as words with the same length and same number of characters in any order. Eg: bat/tab/abt are anagrams aabb/baba/bbaa/abab - anagrams abcd/abce - are not anagrams (different characters) aaab, aabb - are not anagrams (different character count) Given a list of words - {abcd, bbb, abc, bat, cat, yyyyxxxx, tab, atb, rat, cab, xxyyxxyyxx, atb} Print out the anagram pairs - {{abc, cab}, {bat, tab, atb, atb}} Assuming that the input is of type [a-z], can you optimize the solution. With anagrams all is simple - they easily are if to compare the sorted copies of lines. And here with optimization I and did not understand. I so understand, sense there in generation unique for every line but how to make identical to the different lines containing the same dial-up of letters, I yet did not understand. The colleague looked and told supposedly "about, here all is simple - it is necessary to use prime numbers". If I correctly understand, it is necessary to select prime numbers from this variant from 2 and more (and can and from 3, it is not assured) and to take result of multiplication. But 26 prime number in this variant will be 101, i.e. for everyone ' z ' we need to multiply on 101. Then 6. 7 letters ' z ' give which gets out for limits 64 bit. Prompt, what here would be the correct algorithm? And, what is more interesting - prompt, it is necessary to look at what else useful methods of hash coding better to understand this subject?