binary search, bias to the left
• 39 words • 1 min • updated
Prefer:
python
mid = left + (right - left) // 2Instead of:
python
mid = (left + right) // 2…to avoid a potential integer overflow.
Not a real concern in Python, but still a best, defensive practice. ∎
Connections
Shared tags