bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumArrays & HashingLC 249

Group Shifted Strings

We can shift a string by shifting each of its letters to its successive letter. For example, "abc " can be shifted to be "bcd ". We can keep shifting the string to form a sequence. For example, we can keep shifting "abc " to form the sequence: "abc " -> "bcd " -> ... -> "xyz ". Given an array of strings strings, group all strings[i] that belong to the same shifting sequence. You may return the answer in any order.

Asked at 4 companies
AmazonFacebookGoogle
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode