Returning 1 revery time

code- https://ide.codingblocks.com/s/232017

i tried to correct it myself but still it is not helping

I have edited your code… Try to submit it now…
You have to initialise ans=-1, and you need to sort the array first before using the binary search … and in the bool function you need to traverse from 1st element rather than 0th element…