set in c++ implementation code example
Example: set in c++
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
void setDemo()
{
set<int> S;
S.insert(1);
S.insert(2);
S.insert(-1);
S.insert(-10);
S.erase(1);
for(int x:S){
cout<<x<<" ";
}
auto it = S.find(-1);
if (it == S.end()){
cout<<"not Present\n";
}else{
cout <<" present\n";
cout << *it <<endl;
}
auto it2 = S.lower_bound(-1);
auto it3 = S.upper_bound(-1);
cout<<*it2<<" "<<*it3<<endl;
}
int main() {
setDemo();
return 0;
}