https://leetcode.com/problems/split-strings-by-separator/description/
Split Strings by Separator - LeetCode
Can you solve this real interview question? Split Strings by Separator - Given an array of strings words and a character separator, split each string in words by separator. Return an array of strings containing the new strings formed after the splits, excl
leetcode.com
1 2 3 4 5 6 7 8 9 | class Solution: def splitWordsBySeparator(self, words: List[str], separator: str) -> List[str]: answer = [] for x in words: x = x.replace(separator, ' ') answer.extend(x.split()) return answer | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2974. Minimum Number Game (0) | 2024.01.05 |
---|---|
leetcode 2643. Row With Maximum Ones (1) | 2024.01.02 |
leetcode 2824. Count Pairs Whose Sum is Less than Target (1) | 2024.01.02 |
leetcode 2729. Check if The Number is Fascinating (0) | 2023.12.29 |
leetcode 2903. Find Indices With Index and Value Difference I (0) | 2023.12.28 |
댓글