Amazon Interview Question

binary search and follow up