20241024 finished.

This commit is contained in:
2024-10-24 09:08:13 +08:00
parent 3102da99a8
commit bce8de1c85
266 changed files with 2321 additions and 2014 deletions

View File

@@ -3,7 +3,6 @@
*/
pub struct Solution {}
// submission codes start here
use std::collections::HashMap;
@@ -14,7 +13,7 @@ impl Solution {
if words.len() != pattern.len() {
return false;
}
let mut map = HashMap::new();
let mut reverse_map = HashMap::new();
@@ -23,7 +22,7 @@ impl Solution {
if *entry != word {
return false;
}
}
let entry = reverse_map.entry(word).or_insert(c);
@@ -44,6 +43,9 @@ mod tests {
#[test]
fn test_290() {
assert!(Solution::word_pattern("abba".to_owned(), "dog cat cat dog".to_owned()));
assert!(Solution::word_pattern(
"abba".to_owned(),
"dog cat cat dog".to_owned()
));
}
}