From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/word_pattern.rs | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 other/word_pattern.rs (limited to 'other/word_pattern.rs') diff --git a/other/word_pattern.rs b/other/word_pattern.rs deleted file mode 100644 index 6161b40..0000000 --- a/other/word_pattern.rs +++ /dev/null @@ -1,26 +0,0 @@ -struct Solution; - -impl Solution { - pub fn word_pattern(pattern: String, s: String) -> bool { - use std::collections::{HashMap, HashSet}; - if pattern.len() != s.matches(' ').count() + 1 { - return false; - } - let (mut hm, mut word_set) = (HashMap::new(), HashSet::new()); - for (word, c) in s.split_ascii_whitespace().zip(pattern.chars()) { - if let Some(w) = hm.insert(c, word) { - if w != word { - return false; - } - } else if !word_set.insert(word) { - return false; - } - } - true - } -} - -fn main() { - let (pattern, s) = (String::from("abba"), String::from("dog cat cat dog")); - print!("{}", Solution::word_pattern(pattern, s)); -} -- cgit v1.2.3