Amazon interview question

It was a leetcode medium binary search question.