Honestbee interview question

Check if a string of parentheses is valid. For example, '(())()' is valid, '()())' is not.

Interview Answer

Anonymous

27 Jan 2019

function validParenthesesStr(str) { if (!str) return false; let newStr = str; while(newStr.includes('()')) { newStr = newStr.replace(/\(\)/g, ''); } return newStr.length === 0; }