Pregunta de entrevista de Amazon

It was a leetcode medium binary search question.