pass 208 string medium

This commit is contained in:
Mhrooz 2024-05-25 16:38:18 +02:00
parent 364ad7a999
commit 8b067e91be

26
208-240525-pass/main.py Normal file
View File

@ -0,0 +1,26 @@
class Trie:
def __init__(self):
self.l = []
def insert(self, word: str) -> None:
self.l.append(word)
def search(self, word: str) -> bool:
for s in self.l:
if s == word:
return True
return False
def startsWith(self, prefix: str) -> bool:
for s in self.l:
if s.startswith(prefix):
return True
return False
# Your Trie object will be instantiated and called as such:
# obj = Trie()
# obj.insert(word)
# param_2 = obj.search(word)
# param_3 = obj.startsWith(prefix)