i am unable to find mistake in my code, what should be changes in this one?
Lower and bound question
if element not found then lower_bound and upper_bound doesn’t return last index
The lower_bound() method in C++ is used to return an iterator pointing to the first element in the range [first, last) which has a value not less than val. This means that the function returns the index of the next smallest number just greater than or equal to that number.
hence your condition is wrong
if(lb-a==n ){
cout<<-1<<" "<<-1<<endl;
}
i have done some changes to your code
Modified Code
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.