Array merge P70093


Statement
 

pdf   zip   main.cc   main.java   main.py

thehtml

Write a function that merges the sorted vectors v1 and v2 and returns the result, repeated elements included. For instance, the result of merging a vector with 2, 3 and 5 with a vector with 3, 5, 5 and 7 is a vector with 2, 3, 3, 5, 5, 5 and 7.

Interface

C++
vector<double> merge(const vector<double>& v1, const vector<double>& v2);
Java
public static double[] merge(double[] v1, double[] v2);
Python
merge(v1, v2) # returns list
MyPy
merge(v1: list[float], v2: list[float]) -> list[float]:

Precondition

v1 and v2 are sorted in nondecreasig order.

Observation You only need to submit the required procedure; your main program will be ignored.

Information
Author
Salvador Roura
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C++ Java Python
User solutions
C++ Python