Not getting correct output

pls reply sir what is the error

give me 5 min i will check your code

1 Like

There are two problems with your code :-

  1. you are taking input in wrong way, you need to take input of number of cows before the indexes of stalls
  2. you have to sort the indexes of stalls, as only then binary search will output correct answer

corrected code :-

1 Like

thanks a lot sir i got it

1 Like

welcome !!, mark your doubt as resolved if you got the answer :slight_smile: