arraysdsasearching
Finding the first match needs a slightly different condition
Anonymous
Use a half-open range from lo inclusive to hi exclusive. When the middle value is below the target, move lo past it; otherwise move hi to mid. At the end, lo is the first position whose value is at least the target, or the array length if none exists. This assumes sorted input and takes O(log n).
0