Skip to content

Instantly share code, notes, and snippets.

@whizzzkid
Last active Feb 13, 2017
Embed
What would you like to do?
# This is done!
size = int(raw_input())
def node():
return [0, {}, 0]
words = node()
ans = 1
for s in xrange(size):
if not ans: break
word = str(raw_input())
root = words
for chr in word:
root[0] = 1
if root[2]:
ans = 0
break
if not root[1].get(chr):
root[1][chr] = node()
root = root[1].get(chr)
if root[0]:
ans = 0
else:
root[0] = 1
root[2] = 1
if ans:
print 'GOOD SET'
else:
print 'BAD SET'
print word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment