Zūm interview question

Leetcode medium binary search q.