You are viewing a single comment's thread. Return to all comments →
My answer with Typescript.
Idea is remove couple of bracket when it can, then check remaining [s], if it empty mean it fully valid brackets
function isBalanced(s: string): string { let s_memo = '' while (s_memo != s && s.length > 0) { s_memo = s s = s.replace(/(\[\]|\{\}|\(\))/g, '') } return s.length > 0 ? 'NO' : '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 →
My answer with Typescript.
Idea is remove couple of bracket when it can, then check remaining [s], if it empty mean it fully valid brackets