how to convert array to set in cpp code example
Example 1: how to convert array into set in c++
#include <iostream>
#include <unordered_set>
int main()
{
int A[] = { 1, 2, 3, 4, 5 };
std::unordered_set<int> s;
for (int i: A) {
s.insert(i);
}
for (int i: s) {
std::cout << i << " ";
}
return 0;
}
Example 2: convert array to set c++
set<int> res(arr, arr + sizeArr);