• + 39 comments

    Can be solved in one line:

        String input=sc.next();
        while(input.length() != (input = input.replaceAll("\\(\\)|\\[\\]|\\{\\}", "")).length());
        System.out.println(input.isEmpty());
    

    But no stack used for this :)