249. Group Shifted Strings

Problem

Group strings that belong to the same shifting sequence (can be shifted to form each other).

A shifting sequence is formed by shifting each character in a string by the same amount. For example, "abc" shifted by 1 becomes "bcd", shifted by 2 becomes "cde".

Given an array of strings, group all strings that belong to the same shifting sequence together. Return a list of groups, where each group is a list of strings.

Examples
Input: ["abc","bcd","acef","xyz","az","ba","a","z"]
Output: [["acef"],["a","z"],["abc","bcd","xyz"],["az","ba"]]
Hints
Related Problems

249. Group Shifted Strings

Group strings that belong to the same shifting sequence (can be shifted to form each other).