Created
August 22, 2017 19:56
-
-
Save prithajnath/f81cef022d53a7da13a398573a79e2b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pairs = {")":"(","}":"{","]":"["} | |
stack = [] | |
x = raw_input() | |
balanced = True | |
for i in x: | |
if i in pairs.values(): | |
stack.append(i) | |
else: | |
top = stack.pop() | |
if top == pairs[i]: | |
continue | |
else: | |
balanced = False | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment