249. Group Shifted Strings

Practice Group Shifted Strings for free on NudgeCode: Medium, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Shifting a string moves every letter one step forward in the alphabet, with z wrapping around to a: "abc" -> "bcd", "xyz" -> "yza". Two strings belong to the same shifting sequence if one can be turned into the other by shifting it some number of times.

Group the given strings by shifting sequence and return the groups. Groups and the strings inside a group may be in any order; duplicates in the input stay in the output.

Example

strings = ["abc","bcd","acef","xyz","az","ba","a","z"]
->  [["acef"],["a","z"],["abc","bcd","xyz"],["az","ba"]]

Constraints