static int kth ( int arr1 [ ] , int arr2 [ ] , int m , int n , int k ) {
  int [ ] sorted1 = new int [ m + n ] ;
  int i = 0 , j = 0 , d = 0 ;
  while ( i < m && j < n ) {
    if ( arr1 [ i ] < arr2 [ j ] ) sorted1 [ d ++ ] = arr1 [ i ++ ] ;
    else sorted1 [ d ++ ] = arr2 [ j ++ ] ;
  }
  while ( i < m ) sorted1 [ d ++ ] = arr1 [ i ++ ] ;
  while ( j < n ) sorted1 [ d ++ ] = arr2 [ j ++ ] ;
  return sorted1 [ k - 1 ] ;
}

static int kth ( int arr1 [ ] , int arr2 [ ] , int m , int n , int k ) { int [ ] sorted1 = new int [ m + n ] ; int i = 0 , j = 0 , d = 0 ; while ( i < m && j < n ) { if ( arr1 [ i ] < arr2 [ j ] ) sorted1 [ d ++ ] = arr1 [ i ++ ] ; else sorted1 [ d ++ ] = arr2 [ j ++ ] ; } while ( i < m ) sorted1 [ d ++ ] = arr1 [ i ++ ] ; while ( j < n ) sorted1 [ d ++ ] = arr2 [ j ++ ] ; return sorted1 [ k - 1 ] ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (array_access array: (identifier) index: (update_expression (identifier))))) alternative: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (array_access array: (identifier) index: (update_expression (identifier)))))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (array_access array: (identifier) index: (update_expression (identifier)))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (array_access array: (identifier) index: (update_expression (identifier)))))) (return_statement (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))