Skip to content
LC-2788 Easy LeetCode

2788. Split Strings by Separator

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 75% Topics: Array, String
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n * l)
# Space: O(l)

# string
class Solution(object):
    def splitWordsBySeparator(self, words, separator):
        """
        :type words: List[str]
        :type separator: str
        :rtype: List[str]
        """
        return [w for word in words for w in word.split(separator) if w]

Solution from kamyu104/LeetCode-Solutions · MIT