Skip to content

Instantly share code, notes, and snippets.

View shetty-tejas's full-sized avatar
🚀
Building Stuff

Tejas shetty-tejas

🚀
Building Stuff
View GitHub Profile
@shetty-tejas
shetty-tejas / binary_search.go
Last active April 21, 2026 19:26
Made Easy: Binary Search
// The gist has recursive binary search, but the exact same logic and math rules apply to iterative algorithms as well.
import "errors"
// ---------------------------------------------------------
// Type A
// Should return the index of the exact match.
// If there are duplicates, it will return the index of whichever one it finds first.
// ---------------------------------------------------------