static int KthMinValAfterMconcatenate ( int [ ] A , int N , int M , int K ) {
  ArrayList V = new ArrayList ( ) ;
  for ( int i = 0 ;
  i < M ;
  i ++ ) {
    for ( int j = 0 ;
    j < N ;
    j ++ ) {
      V . add ( A [ j ] ) ;
    }
  }
  Collections . sort ( V ) ;
  return ( ( int ) V . get ( K - 1 ) ) ;
}

static int KthMinValAfterMconcatenate ( int [ ] A , int N , int M , int K ) { ArrayList V = new ArrayList ( ) ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { V . add ( A [ j ] ) ; } } Collections . sort ( V ) ; return ( ( int ) V . get ( K - 1 ) ) ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (return_statement (parenthesized_expression (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))))