2788. Split Strings by Separator
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 75% Topics: Array, String
View full problem on LeetCode Reading material
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
Similar questions