The only thing that needs to be known is that for balanced brackets, one can keep repeatedly removing [] in the string and end up with a blank string. There will never be ] as the first character or [ as the last character.
Solution 1
function isBalanced(str) {
while (true) {
str = str.replace('[]', '');
if(str.length==0){
return true;
}
if(str[0]==']'||str[str.length-1]=='['){
return false;
}
}
}
for the reason above, I don’t think your solution can be added to the guide. I am unlisting this tooic but leaving it open in case you want to propose a different solution