Practice/Meta/Leetcode 249. Group Shifted Strings
CodingMust
Given an array of strings, group together all strings that are equivalent under alphabetical shifting. Two strings belong to the same shift group if you can transform one into the other by shifting every character by the same amount in the alphabet, with wraparound from 'z' to 'a'.
For example, "abc" can be shifted to "bcd" by shifting each character forward by 1 position. Similarly, "xyz" can be shifted to "yza" by the same +1 shift pattern.
Return the grouped strings in any order. Within each group, the strings can appear in any order.
Example 1:
` Input: strings = ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"] Output: [["abc","bcd","xyz"],["acef"],["az","ba"],["a","z"]] Explanation:
Example 2:
Input: strings = ["abc", "def", "ghi"] Output: [["abc","def","ghi"]] Explanation: All three strings have the same shift pattern (0,1,2)
Example 3:
Input: strings = ["a"] Output: [["a"]] Explanation: Single string forms its own group