static void maxProductSum ( String str , int m ) {
  int n = str . length ( ) ;
  int product = 1 , sum = 0 ;
  for ( int i = 0 ;
  i < m ;
  i ++ ) {
    sum += ( str . charAt ( i ) - '0' ) ;
    product *= ( str . charAt ( i ) - '0' ) ;
  }
  int maxProd = product ;
  int maxSum = sum ;
  for ( int i = m ;
  i < n ;
  i ++ ) {
    product = product * ( str . charAt ( i ) - '0' ) / ( ( str . charAt ( i - m ) ) - '0' ) ;
    sum = sum + ( str . charAt ( i ) - '0' ) - ( ( str . charAt ( i - m ) ) - '0' ) ;
    maxProd = Math . max ( maxProd , product ) ;
    maxSum = Math . max ( maxSum , sum ) ;
  }
  System . out . println ( "Maximum Product = " + maxProd ) ;
  System . out . println ( "\nMaximum Sum = " + maxSum ) ;
}

static void maxProductSum ( String str , int m ) { int n = str . length ( ) ; int product = 1 , sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { sum += ( str . charAt ( i ) - '0' ) ; product *= ( str . charAt ( i ) - '0' ) ; } int maxProd = product ; int maxSum = sum ; for ( int i = m ; i < n ; i ++ ) { product = product * ( str . charAt ( i ) - '0' ) / ( ( str . charAt ( i - m ) ) - '0' ) ; sum = sum + ( str . charAt ( i ) - '0' ) - ( ( str . charAt ( i - m ) ) - '0' ) ; maxProd = Math . max ( maxProd , product ) ; maxSum = Math . max ( maxSum , sum ) ; } System . out . println ( " Maximum ▁ Product ▁ = ▁ " + maxProd ) ; System . out . println ( " \n Maximum ▁ Sum ▁ = ▁ " + maxSum ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) right: (parenthesized_expression (binary_expression left: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))) right: (character_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) right: (parenthesized_expression (binary_expression left: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))) right: (character_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier)))))))