static boolean checkRedundancy ( String s ) {
  Stack < Character > st = new Stack < > ( ) ;
  char [ ] str = s . toCharArray ( ) ;
  for ( char ch : str ) {
    if ( ch == ')' ) {
      char top = st . peek ( ) ;
      st . pop ( ) ;
      boolean flag = true ;
      while ( top != '(' ) {
        if ( top == '+' || top == '-' || top == '*' || top == '/' ) {
          flag = false ;
        }
        top = st . peek ( ) ;
        st . pop ( ) ;
      }
      if ( flag == true ) {
        return true ;
      }
    }
    else {
      st . push ( ch ) ;
    }
  }
  return false ;
}

static boolean checkRedundancy ( String s ) { Stack < Character > st = new Stack < > ( ) ; char [ ] str = s . toCharArray ( ) ; for ( char ch : str ) { if ( ch == ' ) ' ) { char top = st . peek ( ) ; st . pop ( ) ; boolean flag = true ; while ( top != ' ( ' ) { if ( top == ' + ' || top == ' - ' || top == ' * ' || top == ' / ' ) { flag = false ; } top = st . peek ( ) ; st . pop ( ) ; } if ( flag == true ) { return true ; } } else { st . push ( ch ) ; } } return false ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (character_literal)) right: (binary_expression left: (identifier) right: (character_literal))) right: (binary_expression left: (identifier) right: (character_literal))) right: (binary_expression left: (identifier) right: (character_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (block (return_statement (true))))) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (return_statement (false))))