2788. Split Strings by Separator Easy

@problem@discussion
#Array#String



1/**
2 * [2788] Split Strings by Separator
3 *
4 * Given an array of strings words and a character separator, split each string in words by separator.
5 * Return an array of strings containing the new strings formed after the splits, excluding empty strings.
6 * Notes
7 * 
8 * 	separator is used to determine where the split should occur, but it is not included as part of the resulting strings.
9 * 	A split may result in more than two strings.
10 * 	The resulting strings must maintain the same order as they were initially given.
11 * 
12 *  
13 * <strong class="example">Example 1:
14 * 
15 * Input: words = ["one.two.three","four.five","six"], separator = "."
16 * Output: ["one","two","three","four","five","six"]
17 * Explanation: In this example we split as follows:
18 * "one.two.three" splits into "one", "two", "three"
19 * "four.five" splits into "four", "five"
20 * "six" splits into "six" 
21 * Hence, the resulting array is ["one","two","three","four","five","six"].
22 * <strong class="example">Example 2:
23 * 
24 * Input: words = ["$easy$","$problem$"], separator = "$"
25 * Output: ["easy","problem"]
26 * Explanation: In this example we split as follows: 
27 * "$easy$" splits into "easy" (excluding empty strings)
28 * "$problem$" splits into "problem" (excluding empty strings)
29 * Hence, the resulting array is ["easy","problem"].
30 * 
31 * <strong class="example">Example 3:
32 * 
33 * Input: words = ["|||"], separator = "|"
34 * Output: []
35 * Explanation: In this example the resulting split of "|||" will contain only empty strings, so we return an empty array []. 
36 *  
37 * Constraints:
38 * 
39 * 	1 <= words.length <= 100
40 * 	1 <= words[i].length <= 20
41 * 	characters in words[i] are either lowercase English letters or characters from the string ".,|$#@" (excluding the quotes)
42 * 	separator is a character from the string ".,|$#@" (excluding the quotes)
43 * 
44 */
45pub struct Solution {}
46
47// problem: https://leetcode.com/problems/split-strings-by-separator/
48// discuss: https://leetcode.com/problems/split-strings-by-separator/discuss/?currentPage=1&orderBy=most_votes&query=
49
50// submission codes start here
51
52impl Solution {
53    pub fn split_words_by_separator(words: Vec<String>, separator: char) -> Vec<String> {
54        vec![]
55    }
56}
57
58// submission codes end
59
60#[cfg(test)]
61mod tests {
62    use super::*;
63
64    #[test]
65    fn test_2788() {
66    }
67}
68


Back
© 2025 bowen.ge All Rights Reserved.