Sir, what is the mistake in my code ? please help me to find out the my mistake

here is my code --> https://ide.codingblocks.com/s/453190

hello @chandreshmaurya
u r assuming that if key is not presnt then it will return end of the array which is wrong.

lower bound return iterator that is greater than or equal to key.
upper bound return iterator that is greater than key.

for ex->
if array is
1 2 3 7 8 9
and key is 4
the lower/upper bound will return iterator of 7 which is clearly not the end of the array.

first use binary search to check wheter key is present or not.
if not present then simply print -1 -1
otherwise use ur current logic

sir, i did as u told. but, still i failed in some test cases. my code --> https://ide.codingblocks.com/s/453223

check now->

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.