z wraps around to a. For example, abc shifts to bcd, and xyz shifts to yza. A word can be shifted any number of times.
Given a list of lowercase words words, group together the words that can be turned into one another by shifting, and return the list of groups. The order of the groups and the order of words inside a group do not matter. If a word appears several times, every occurrence goes into its group.words=["dog", "eph", "a", "q", "ace", "bdf"] → [['dog', 'eph'], ['a', 'q'], ['ace', 'bdf']]
Shifting dog by 1 gives eph; any one-letter word can be shifted into any other; ace shifts into bdf.
words=["za", "ab", "ba"] → [['za', 'ab'], ['ba']]
Shifting za by 1 gives ab (after z comes a again). In ba the second letter comes before the first rather than after, so it gets its own group.
words[i] consists of lowercase English letterswords=["dog", "eph", "a", "q", "ace", "bdf"]
[['dog', 'eph'], ['a', 'q'], ['ace', 'bdf']]
Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.