Valid Parentheses

public class Solution {
    public boolean isValid(String s) {
        int length;

        do {
            length = s.length();
            s = s.replace("()", "").replace("{}", "").replace("[]", "");
        } while(length != s.length());

        return s.length() == 0;
    }
}

  

原文地址:https://www.cnblogs.com/yingpu/p/15350621.html