Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.76 KB

File metadata and controls

40 lines (31 loc) · 1.76 KB

< Previous                  Next >

Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:

"abc" -> "bcd" -> ... -> "xyz"

Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.

Example:

Input: ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"],
Output: 
[
  ["abc","bcd","xyz"],
  ["az","ba"],
  ["acef"],
  ["a","z"]
]

Related Topics

[Array] [Hash Table] [String]

Similar Questions

  1. Group Anagrams (Medium)