Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 7x 7x 7x 12x 12x 10x 6x 4x 5x | export default function searchInsert(nums: number[], target: number): number {
let lo = 0
let hi = nums.length - 1
while (lo <= hi) {
const mid = lo + ((hi - lo) >> 1)
if (nums[mid] === target)
return mid
else if (nums[mid] < target)
lo = mid + 1
else hi = mid - 1
}
return lo
}
|