Flipkart interview question

A binary search question with a complex test case.