Remove Outermost Parentheses

Run Settings
LanguageJavascript
Language Version
Run Command
var paren = "(()())(())(()(()))"; var result = ""; var cur = ""; var counter = 0; for(i=0;i<paren.length;i++) { if(paren[i] === '(') { counter++; if(counter > 1){ cur += '('; } }else{ counter--; if(counter === 0){ result += cur; cur = ""; }else{ cur += ')'; } } } console.log(result);
Editor Settings
Theme
Key bindings
Full width
Lines