#K39667. Anagram Pairs Finder
Anagram Pairs Finder
Anagram Pairs Finder
You are given a list of N words. Your task is to find all pairs of distinct words that are anagrams of each other. Two words are anagrams if, after removing all spaces and converting all letters to lowercase, the sorted sequence of characters is the same. In other words, for two words w1 and w2, they are anagrams if:
$$sorted(\text{removeSpaces}(w_1).toLowerCase()) = sorted(\text{removeSpaces}(w_2).toLowerCase())$$
For every pair found, output the pair in lexicographical order (i.e. print the lexicographically smaller word first). If no such pairs exist, output "No anagrams found".
The input is given via standard input and the output should be printed to standard output.
inputFormat
The first line contains an integer N, the number of words. Each of the following N lines contains one word. A word may include spaces.
outputFormat
If one or more anagram pairs are found, print each pair on a new line with the two words separated by a space, ensuring that the lexicographically smaller word comes first in each pair. The pairs themselves should be sorted in lexicographical order. If no anagram pairs are found, output a single line: "No anagrams found".
## sample6
listen
silent
enlist
google
gogole
cat
enlist listen
enlist silent
gogole google
listen silent
</p>