Google Coding Interview Question | Leetcode 249 | Group Shifted Strings

Поділитися
Вставка
  • Опубліковано 19 жов 2024

КОМЕНТАРІ • 3

  • @ggjj3719
    @ggjj3719 3 роки тому +2

    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!

  • @edwardteach2
    @edwardteach2 2 роки тому

    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()

  • @algerienizer
    @algerienizer 3 роки тому +1

    great videos, the audio is very low though