Amazon Interview Question

binary search with bounding check