Skip to content

Commit 5b78f07

Browse files
committed
Runtime: 1 ms (Top 100.0%) | Memory: 2.20 MB (Top 50.0%)
1 parent 4111850 commit 5b78f07

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Runtime: 1 ms (Top 100.0%) | Memory: 2.20 MB (Top 50.0%)
2+
3+
impl Solution {
4+
pub fn uncommon_from_sentences(s1: String, s2: String) -> Vec<String> {
5+
let mut map = std::collections::HashMap::new();
6+
s1.split(' ')
7+
.chain(s2.split(' '))
8+
.for_each(|s| *map.entry(s).or_insert(0) += 1);
9+
map.iter()
10+
.filter_map(|(key, val)| match *val == 1 {
11+
true => Some((*key).to_string()),
12+
false => None,
13+
})
14+
.collect::<Vec<_>>()
15+
}
16+
}

0 commit comments

Comments
 (0)