Problem:
How to identify or count the number of similar words having same letters(count of letters should be same, order can be anything).
For example, below are the words:
aabb, aaab, abbb, abaa, abab, aabc, caba, babb, baaa
Below are the similar words are:
aabb, abab
aaab, abaa, baaa
abbb, babb
aabc, caba
Below are the basic logics I got for this is:
Method1: First sort the letters in individual words. Compare the sorted words.
Method2: Comparing each letter of each word across remaining words. (This will be the highest count of iterations)
Please suggest some better logics for solving..