java 15 lines - new idea !


  • 0
    Z


    String rsStr = s;
    if ((s.length()%2)==0) {
    for(int i=0; i<s.length()/2; i++) {
    if (rsStr=="") {
    return true;
    } else {
    rsStr = rsStr.replace("()", "").replace("{}", "").replace("[]", "");
    }
    }
    if (rsStr.length()!=0) {
    return false;
    } else {
    return true;
    }
    } else {
    return false;
    }


Log in to reply
 

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