#Skip to menu

Count anagrams

First read the problem description.

A easy way to check if a word is the anagram of another is to sort both words and to compare them. We need to count the amount of anagrams contained in the input, to do so we read each word, sort it and insert it into a data structure. If the sorted word was already inserted it means it’s an anagram, otherwise we just insert it. For sorting we’ll use Insertion sort which works well for small words. The words will be stored in a Ternary search tree.


Source code of the solution(s):