can you please let me know
How the answer is 6
I assume the question was
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int>v={20, 40, 30, 10 , 50, 30};
sort(v.begin(), v.end());
cout<<upper_bound(v.begin(), v.end(), 30)-v.begin();
return 0;
}
here answer is 6 because
upper_bound(v.begin(), v.end(), 30)
gives an iterator at v.end()
so v.end()-v.begin() = size of v = 6
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.