You are viewing a single comment's thread. Return to all comments →
Python 3 Simple and Easy solution
def isBalanced(s):
if(len(s)%2==1): return 'NO' res=list() for i in range(len(s)): if(s[i]=='}'): if(len(res)==0 or res.pop()!='{'): return 'NO' elif(s[i]==')'): if(len(res)==0 or res.pop()!='('): return 'NO' elif(s[i]==']'): if(len(res)==0 or res.pop()!='['): return 'NO' else: res.app end(s[i]) if(len(res)==0): return 'YES' else: return 'NO'
Seems like cookies are disabled on this browser, please enable them to open this website
Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
Python 3 Simple and Easy solution
def isBalanced(s):