20240120 Finished

This commit is contained in:
jackfiled 2024-01-20 10:25:01 +08:00
parent 7e49f1316d
commit 6dfb09b4ef
2 changed files with 40 additions and 1 deletions

View File

@ -21,4 +21,5 @@ mod p82_remove_duplicates_from_sorted_list_ii;
mod p2719_count_of_integers; mod p2719_count_of_integers;
mod p2744_find_maximum_number_of_string_pairs; mod p2744_find_maximum_number_of_string_pairs;
mod p2171_removing_minimum_number_of_magic_beans; mod p2171_removing_minimum_number_of_magic_beans;
mod p2809_minimum_time_to_make_array_sum_at_most_x; mod p2809_minimum_time_to_make_array_sum_at_most_x;
mod p2788_split_strings_by_separator;

View File

@ -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<String>, separator: char) -> Vec<String> {
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() {
}
}