CTCI 11.3
binary search