Skip to content

Instantly share code, notes, and snippets.

@j10sanders
Created November 1, 2016 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j10sanders/18d58b2dd8c0a744ca2b49ac0913aa74 to your computer and use it in GitHub Desktop.
Save j10sanders/18d58b2dd8c0a744ca2b49ac0913aa74 to your computer and use it in GitHub Desktop.
def bb(n):
prevstring = ""
while n != prevstring:
prevstring = n
n = n.replace("()", "").replace("[]", "").replace("{}", "")
return "YES" if n == "" else "NO"
t = int(input().strip())
for a0 in range(t):
s = input().strip()
print(bb(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment