We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 98805a2 commit 1b81fc7Copy full SHA for 1b81fc7
design-add-and-search-words-data-structure/yhkee0404.rs
@@ -22,7 +22,7 @@ impl WordDictionary {
22
}
23
24
25
- // T(n) = S(n) = O(26n) = O(n)
+ // T(n) = S(n) = O(n)
26
fn add_word(&mut self, word: String) {
27
let mut t = &mut self.trie;
28
for c in word.chars() {
@@ -37,7 +37,7 @@ impl WordDictionary {
37
return Self::search_from_index(&self.trie, &word)
38
39
40
- // T(n) = S(n) = ((26^2)n) = O(n)
+ // T(n) = S(n) = O((n - 2) * 26^2) = O(n)
41
fn search_from_index(trie: &Trie, word: &str) -> bool {
42
return match word.chars()
43
.next() {
0 commit comments