Skip to content

mid [terminology]

Terminology

Usage

  • Use for the midpoint of a range or a partition position.
  • It may be an index or a value, depending on whether the surrounding bounds are positional or value-based.
# ...
l, r = 0, len(nums) - 1
while l <= r:
    mid = (l + r) // 2
    if nums[mid] < target:
        l = mid + 1
    else:
        r = mid - 1
return l

See 35. Search Insert Position.