Answers for "how to convert array into set in c++"

C++
0

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;
}
Posted by: Guest on January-19-2021
0

convert array to set c++

set<int> res(arr, arr + sizeArr);
Posted by: Guest on March-27-2021

Code answers related to "how to convert array into set in c++"

Browse Popular Code Answers by Language