Perform the following shift operations on a string:
"abc" can be right-shifted to "bcd" or "xyz" can be right-shifted to "yza"."bcd" can be left-shifted to "abc" or "yza" can be left-shifted to "xyz".We can keep shifting the string in both directions to form an endless shifting sequence.
"abc" to form the sequence: ... <-> "abc" <-> "bcd" <-> ... <-> "xyz" <-> "yza" <-> .... <-> "zab" <-> "abc" <-> ...You are given an array of strings strings, group together all strings[i] that belong to the same shifting sequence. You may return the answer in any order.
Example 1:
Input: strings = ["abc","bcd","acef","xyz","az","ba","a","z"]
Output: [["acef"],["a","z"],["abc","bcd","xyz"],["az","ba"]]
Example 2:
Input: strings = ["a"]
Output: [["a"]]
Constraints:
1 <= strings.length <= 2001 <= strings[i].length <= 50strings[i] consists of lowercase English letters.