Valid Parentheses Algorithm Effeciency What do you think of my Algorithm?

I start to eliminate the nearest valid parentheses 

and if string.length == 0 so it's valid



/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function(s) {
    while (s.length != 0 &amp;&amp; s.includes("[]") || s.includes("()") || s.includes("{}")) {
        s = s.replace("[]", "");
        s = s.replace("()", "");
        s = s.replace("{}", "");
    }
    return s.length &lt; 1
};

console.log(isValid("({((}{}))})"));
console.log(isValid("({(())})"));
It's correct, but it's ineffiecent. It uses O(n^2) time in the worst case (for instance, if the input's ((((((..)))))))).

You can do better than that by iterating over the input string and keeping a stack of brackets, pushing opening brackets to it and popping when you encounter closign brackets, checking that it's not empty and that the top bracket matches the current one.