solve binary search