From 6dfb09b4ef7de91974651ccbf198e30a24f29098 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sat, 20 Jan 2024 10:25:01 +0800 Subject: [PATCH] 20240120 Finished --- src/problem/mod.rs | 3 +- .../p2788_split_strings_by_separator.rs | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/problem/p2788_split_strings_by_separator.rs diff --git a/src/problem/mod.rs b/src/problem/mod.rs index a7dd1b9..bfcc23c 100644 --- a/src/problem/mod.rs +++ b/src/problem/mod.rs @@ -21,4 +21,5 @@ mod p82_remove_duplicates_from_sorted_list_ii; mod p2719_count_of_integers; mod p2744_find_maximum_number_of_string_pairs; mod p2171_removing_minimum_number_of_magic_beans; -mod p2809_minimum_time_to_make_array_sum_at_most_x; \ No newline at end of file +mod p2809_minimum_time_to_make_array_sum_at_most_x; +mod p2788_split_strings_by_separator; \ No newline at end of file diff --git a/src/problem/p2788_split_strings_by_separator.rs b/src/problem/p2788_split_strings_by_separator.rs new file mode 100644 index 0000000..e9a722b --- /dev/null +++ b/src/problem/p2788_split_strings_by_separator.rs @@ -0,0 +1,38 @@ +/** + * [2788] Split Strings by Separator + */ +pub struct Solution {} + + +// submission codes start here + +impl Solution { + pub fn split_words_by_separator(words: Vec, separator: char) -> Vec { + let mut result = Vec::new(); + + for s in &words { + for i in s.split(separator) { + let word = String::from(i); + + if word.is_empty() { + continue; + } + + result.push(word) + } + } + + result + } +} + +// submission codes end + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_2788() { + } +}