static void search ( String pat , String txt ) {
  int M = pat . length ( ) ;
  int N = txt . length ( ) ;
  char [ ] countP = new char [ MAX ] ;
  char [ ] countTW = new char [ MAX ] ;
  for ( int i = 0 ;
  i < M ;
  i ++ ) {
    ( countP [ pat . charAt ( i ) ] ) ++ ;
    ( countTW [ txt . charAt ( i ) ] ) ++ ;
  }
  for ( int i = M ;
  i < N ;
  i ++ ) {
    if ( compare ( countP , countTW ) ) System . out . println ( "Found at Index " + ( i - M ) ) ;
    ( countTW [ txt . charAt ( i ) ] ) ++ ;
    countTW [ txt . charAt ( i - M ) ] -- ;
  }
  if ( compare ( countP , countTW ) ) System . out . println ( "Found at Index " + ( N - M ) ) ;
}

static void search ( String pat , String txt ) { int M = pat . length ( ) ; int N = txt . length ( ) ; char [ ] countP = new char [ MAX ] ; char [ ] countTW = new char [ MAX ] ; for ( int i = 0 ; i < M ; i ++ ) { ( countP [ pat . charAt ( i ) ] ) ++ ; ( countTW [ txt . charAt ( i ) ] ) ++ ; } for ( int i = M ; i < N ; i ++ ) { if ( compare ( countP , countTW ) ) System . out . println ( " Found ▁ at ▁ Index ▁ " + ( i - M ) ) ; ( countTW [ txt . charAt ( i ) ] ) ++ ; countTW [ txt . charAt ( i - M ) ] -- ; } if ( compare ( countP , countTW ) ) System . out . println ( " Found ▁ at ▁ Index ▁ " + ( N - M ) ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (type_identifier) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (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 (update_expression (parenthesized_expression (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) (expression_statement (update_expression (parenthesized_expression (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))))) (expression_statement (update_expression (parenthesized_expression (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) (expression_statement (update_expression (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))))))))