This is just a simple sorting problem; anyone can code it from scratch! But, we want to code it fast, and take advantage of functions already provided with the language
Java -> comparator with struct
C++ -> pairs
We should just check all the orderings of the words.
C++ -> next_permutation
Java -> recursion
To quickly check if we've seen a problem before, we should design some sort of canonical form. Let's sort the characters!
e.g. abcdeabcde -> aabbccddee
edcbaedcba -> aabbccddee
Now it is obvious to see the two problems are the same!