You are viewing a single comment's thread. Return to all comments →
from functools import reduce def isBalanced(s): return 'NO' if reduce(lambda x, y: x.replace('()', '').replace('[]', '').replace('{}', ''), s[:len(s)//2+1], s) else 'YES'
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 →