Quant Memo
Coding/●●●●●

Group strings by a common letter shift

Two lowercase strings belong to the same shift group if you can turn one into the other by shifting every letter forward by the same amount, wrapping around from z back to a. So "abc", "bcd", and "xyz" are all in one group, and "az", "ba" are in another (a+1 = b, z+1 = a).

words = ["abc", "bcd", "xyz", "az", "ba", "acd"]
-> [["abc", "bcd", "xyz"], ["az", "ba"], ["acd"]]

Group the strings. Aim for linear time in total characters.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions