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 4b11e52 commit ec75cf3Copy full SHA for ec75cf3
implement-trie-prefix-tree/HodaeSsi.py
@@ -0,0 +1,31 @@
1
+# 시간복잡도: O(n) (n은 문자열의 길이)
2
+# 공간복잡도: O(n) (n은 문자열의 길이)
3
+class Trie:
4
+ def __init__(self):
5
+ self.root = {}
6
+ self.end = False
7
+
8
+ def insert(self, word: str) -> None:
9
+ node = self.root
10
+ for char in word:
11
+ if char not in node:
12
+ node[char] = {}
13
+ node = node[char]
14
+ node[self.end] = True
15
16
+ def search(self, word: str) -> bool:
17
18
19
20
+ return False
21
22
+ return self.end in node
23
24
+ def startsWith(self, prefix: str) -> bool:
25
26
+ for char in prefix:
27
28
29
30
+ return True
31
0 commit comments