Skip to content

Commit 1b81fc7

Browse files
authored
design add and search words data structure fixed with intermediate analyses
1 parent 98805a2 commit 1b81fc7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

design-add-and-search-words-data-structure/yhkee0404.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl WordDictionary {
2222
}
2323
}
2424

25-
// T(n) = S(n) = O(26n) = O(n)
25+
// T(n) = S(n) = O(n)
2626
fn add_word(&mut self, word: String) {
2727
let mut t = &mut self.trie;
2828
for c in word.chars() {
@@ -37,7 +37,7 @@ impl WordDictionary {
3737
return Self::search_from_index(&self.trie, &word)
3838
}
3939

40-
// T(n) = S(n) = ((26^2)n) = O(n)
40+
// T(n) = S(n) = O((n - 2) * 26^2) = O(n)
4141
fn search_from_index(trie: &Trie, word: &str) -> bool {
4242
return match word.chars()
4343
.next() {

0 commit comments

Comments
 (0)