Group words that share a letter pattern
Two words have the same pattern if one can be turned into the other by a consistent one-to-one relabeling of letters. So "egg" and "add" match (both are "one letter, then a doubled second letter"), and so do "bar", "cab", "xyz" (three distinct letters).
words = ["egg", "add", "foo", "bar", "cab", "xyz"]
-> [["egg", "add", "foo"], ["bar", "cab", "xyz"]]
Group the words by pattern. Aim for linear time in the total number of characters.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.