Winning cb scholarship

all test cases not passing
here is my code

modified code (only one test case failing…)

Dry run your code on (6 7 2 1) and look for possible errors

sorry this is the code: https://ide.codingblocks.com/s/156937\

In your code, value of ans in line 13 (ans = mid) is lost when ans is recalculated in line 9.

sol - save the value of “mid” in a new variable say “res” and at the end return the value stored in variable “res”.
like here - https://ide.codingblocks.com/s/156946

1 Like