Upper bound using algorithm

Why it is passing only one test case ?

In your while loop, instead of checking your condition with n , check it with m in line nUmber 20 & 26 :slight_smile:

we will check with ‘n’ na if not found then lower and upper bound will reach at n the (end of array +1)

But your n is the size of array whereas m is the number you have to find.

Moreover the conditions you have implemented will also give you wrong output.
Try using this implementation as the code you have implemented won’t give you a correct output https://ide.codingblocks.com/s/314537?_ga=2.160865917.1910915811.1600971249-586887292.1600971249

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.