Last updated
Was this helpful?
Last updated
Was this helpful?
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:
Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.
For example, given:["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"]
,
A solution is:
这题要按照字母之间位移量来把字符串分类。这里主要得注意,ba和az的情况,因为b -> a的位移是-25,我们要加上26,mod一下,把它跟az归到一组。T:O(n* avg len of string), S:O(n)