Array union X77575


Statement
 

pdf   zip   main.cc

html

Write a function that returns a sorted vector with the union of two sorted vectors v1 and v2. The result must have the elements in v1 and the elements in v2, without repetitions. For example, the union of a vector with 1, 2, 2, 5, 5, 7 and a vector with 2, 3, 3, 7 is a vector with 1, 2, 3, 5, 7.

Interface

vector<double> array_union(const vector<double>& v1, const vector<double>& v2);

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

Public test cases
  • Input

    6
    1 2 2 5 5 7
    4
    2 3 3 7
    

    Output

    5
    1 2 3 5 7
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    C++
    User solutions
    C++