Binary Search In Swift Without Off-By-One Errors
Binary search is less scary when you commit to one invariant. Let's implement lowerBound, upperBound, exact search, and insertion index in Swift using half-open ranges and test cases that catch the usual mistakes.
Read more