Code AnalysisIntermediate 50s
Trace: Balanced Parentheses
What is printed?
Starter code
const s = "(()())";
let st = [],
ok = true;
for (const ch of s) {
if (ch === "(") st.push(ch);
else if (!st.pop()) ok = false;
}
console.log(ok && st.length === 0);Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.