#include <iostream>
#include <vector>
#include <set>
using std::vector;
/*
Function: mergeVectors
Purpose: Combine three integer vectors into a single vector.
*/
vector<int> mergeVectors(const vector<int>& a, const vector<int>& b, const vector<int>& c) {
vector<int> merged;
merged.insert(merged.end(), a.begin(), a.end());
merged.insert(merged.end(), b.begin(), b.end());
merged.insert(merged.end(), c.begin(), c.end());
return merged;
}
/*
Function: uniqueSorted
Purpose: Convert a vector into a sorted list with unique elements.
Uses std::set because it automatically sorts and removes duplicates.
*/
vector<int> uniqueSorted(const vector<int>& arr) {
std::set<int> s(arr.begin(), arr.end()); // removes duplicates + sorts
return vector<int>(s.begin(), s.end());
}
int main() {
// Example input vectors
vector<int> arr1 = {5, 1, 14, 3, 8, 9, 1, 1, 7};
vector<int> arr2 = {3, 5, 7, 2, 3};
vector<int> arr3 = {2, 9, 8};
// Step 1: Merge all vectors
vector<int> merged = mergeVectors(arr1, arr2, arr3);
// Step 2: Create sorted unique list
vector<int> result = uniqueSorted(merged);
// Step 3: Print result
std::cout << "Sorted unique vector: ";
for (int x : result) {
std::cout << x << " ";
}
}
/*
run:
Sorted unique vector: 1 2 3 5 7 8 9 14
*/