Search in a Big Sorted Array
ID: 447; medium; 在大数组中查找
Solution 1 (Java)
Notes
We do not know the upper bound of the range, so we double
right
starting from 1 until the element at right is larger than thetarget
. Thus, we have a valid range containing atarget
.We cannot return
mid
immediately if we found atarget
because the problem requires the first position of thetarget
.
Last updated