Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Trie:
- def __init__(self):
- self.nodes = dict()
- self.end = False
- def insert(self, s, i):
- if i == len(s) - 1:
- self.end = True
- if len(self.nodes):
- return False
- return True
- if self.end:
- return False
- if s[i] not in self.nodes:
- self.nodes[s[i]] = Trie()
- return self.nodes[s[i]].insert(s, i+1)
- w = input().split()
- flg = True
- t = Trie()
- for x in w:
- v = t.insert(x, 0)
- if not v:
- flg = False
- break
- print("Good" if flg else "not good")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement