Thanks for explaining the question. It would be perfect if your voice sound can be higher. It's hard for me to hear even I turned my volume to the highest of my computer. I like the style your analyze the problem. NJ!
Thanks! My python implementation: class Solution(object): def groupStrings(self, strings): """ :type strings: List[str] :rtype: List[List[str]] """ mapp = collections.defaultdict(list) for s in strings: arr = [0] * 26 for i in range(len(s) - 1): a = ord(s[i]) b = ord(s[i+1]) diff = b - a arr[diff] += 1 mapp[tuple(arr)].append(s) return mapp.values()
Thanks for explaining the question. It would be perfect if your voice sound can be higher. It's hard for me to hear even I turned my volume to the highest of my computer. I like the style your analyze the problem. NJ!
Thanks! My python implementation:
class Solution(object):
def groupStrings(self, strings):
"""
:type strings: List[str]
:rtype: List[List[str]]
"""
mapp = collections.defaultdict(list)
for s in strings:
arr = [0] * 26
for i in range(len(s) - 1):
a = ord(s[i])
b = ord(s[i+1])
diff = b - a
arr[diff] += 1
mapp[tuple(arr)].append(s)
return mapp.values()
great videos, the audio is very low though