Identify error in code

Sir , I am not able to identify the error in my code. It compiles and tests correctly but on submitting all the test cases fail.

hello @learninggood

u have hardcoded 5 ,which is not correct, u need to make generic logic.

also 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 lower bound ,upper bound

check ur updated code hre->

sir now the code is not being submitted due to TLE . what should I do?

i have already shared ur corrected code ,pls check

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.