I don't understand how upper_bound work or give output
here's my code:
#include<bits/stdc++.h>
using namespace std;
int main(){
std::vector<int> v({2,4,1,3});
std::vector<int> v2({2,3,1,4});
auto it=upper_bound(v.begin(), v.end(),2);
auto it2=upper_bound(v2.begin(), v2.end(),2);
cout<<*it<<endl;
cout<<*it2;
return 0;}
I think upper_bound() give me next greater element of the vectors. So as according the value of *it and *it2 will be 4 and 3. But when I run the code, the output is *it=3 and *it2=4.
Output Screenshot link: https://prnt.sc/NqBCnAXtQR8P