Array symmetric difference X23420


Statement
 

pdf   zip   main.cc

Write a function that returns a sorted vector with the symmetric difference of two sorted vectors v1v_1 and v2v_2. The result must have the elements in v1v_1 that are not in v2v_2 and the elements in v2v_2 that are not in v1v_1, without repetitions. For example, the symmetric difference of a vector with 1,2,2,5,5,71, 2, 2, 5, 5, 7 and a vector with 2,3,3,72, 3, 3, 7 is a vector with 1,3,51, 3, 5.

Interface

vector<double> symmetric_difference(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

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