Skip to content

Commit 775eb7c

Browse files
authored
Update implement-magic-dictionary.py
1 parent e31ac2a commit 775eb7c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Python/implement-magic-dictionary.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@ def __init__(self):
3232
self.trie = _trie()
3333

3434

35-
def buildDict(self, dict):
35+
def buildDict(self, dictionary):
3636
"""
3737
Build a dictionary through a list of words
38-
:type dict: List[str]
38+
:type dictionary: List[str]
3939
:rtype: void
4040
"""
41-
for s in dict:
42-
curr = self.trie
43-
for c in s:
44-
curr = curr[c]
45-
curr.setdefault("_end")
41+
for word in dictionary:
42+
reduce(dict.__getitem__, word, self.trie).setdefault("_end")
4643

4744

4845
def search(self, word):

0 commit comments

Comments
 (0)