Google Interview Question

A slightly harder variation of binary search.