Limeroad interview question

A medium level coding problem related to binary search.