MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / search

Method search

676-implement-magic-dictionary.rs:20–37  ·  view source on GitHub ↗
(&self, search_word: String)

Source from the content-addressed store, hash-verified

18 }
19
20 fn search(&self, search_word: String) -> bool {
21 let search_word_len = search_word.len();
22 let search_res = self.mmp.get(&search_word_len);
23 let search_chars = search_word.chars().collect::<Vec<char>>();
24 if search_res == None {
25 false
26 } else {
27 'outer: for chars in search_res.unwrap() {
28 let mut count = 0;
29 for i in 0..search_word_len {
30 if chars[i] != search_chars[i] { count += 1 }
31 if count > 1 { continue 'outer }
32 }
33 if count == 1 { return true }
34 }
35 false
36 }
37 }
38}
39
40fn main() {

Callers 1

mainFunction · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected