Interesting BS problem


#1

One of the most interesting binary search problem which i have solved. One needs to take care of corner cases.
Here is my efficient implementation;

code