Not able to pass all testcases

Why I am not able to pass all the test cases?What is wrong in the code

hello @priyeshant1104
image

use elseif in place of if

we r doing this because we want to make sure that in each iteration only one of the block should execute

It works but I can’t understand why use of elseif is different than using 2 if as for any iteration only one case is possible?

is it because the value of mid will change after 1st if?

yeah right . . . . . . …