Amazon interview question

binary search with bounding check