Skip to content

Practice Split Strings by Separator

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2788
LeetCode Problem

Split Strings by Separator

Problem Statement

Split each string in words at every occurrence of separator. Remove the separators and discard empty pieces. Return all remaining pieces in their original word order and their original order within each word.

Source: Split Strings by Separator on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
words = ["one.two.three","four.five","six"], separator = "."
Output
["one","two","three","four","five","six"]

# Example 2

Input
words = ["$easy$","$problem$"], separator = "$"
Output
["easy","problem"]

# Example 3

Input
words = ["|||"], separator = "|"
Output
[]

Constraints

1 <= words.length <= 100
1 <= words[i].length <= 20
characters in words[i] are either lowercase English letters or characters from the string ".,|$#@" (excluding the quotes)
separator is a character from the string ".,|$#@" (excluding the quotes)

Related LeetCode Problems

Practice more problems similar to Split Strings by Separator.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.