My javascript solution


  • 0
    S
    var isValid = function(s) {
        var i = 0,
            r = /\(\)|\[\]|\{\}/g,
            length = s.length;
        if(length%2==1){return false;}
        while(i<length/2){
            s = s.replace(r,"");
            i++;
        }
        return s==="";
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.