Set lower_bound()

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
    vector<int>v = {1,2,3,4,5,6,7,8,9,10};
    set<int> s(v.begin(), v.end());

    auto t = lower_bound(s.begin(), s.end(), 9);

    if(t == s.end())
        cout << "Not Found." << endl;
    else
        cout << *t << " is Found." << endl;

    return 0;
}

Comments