20240120 Finished
This commit is contained in:
parent
7e49f1316d
commit
6dfb09b4ef
|
@ -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;
|
||||
mod p2809_minimum_time_to_make_array_sum_at_most_x;
|
||||
mod p2788_split_strings_by_separator;
|
38
src/problem/p2788_split_strings_by_separator.rs
Normal file
38
src/problem/p2788_split_strings_by_separator.rs
Normal 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() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user