← Search

Micro-Drill #48 — Left boundary (bisect_left)

Search Target: 15s

Left boundary search finds the first occurrence. Key for range queries and count problems.

lo, hi = 0, len(a)
while lo < hi:
    mid = lo + (hi - lo) // 2
    if a[mid] < target: lo = mid + 1
    else: hi = mid
return lo

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #47 Micro #49 →