Binary Search (Go)
Topics: search, algorithms
Problem
nums is sorted ascending. Return (index, true) of target, or (0, false) if it isn't
present, in O(log n) time.
search([]int{1, 3, 5, 7, 9}, 7) // 3, true
search([]int{1, 3, 5, 7, 9}, 4) // 0, false
Only solution.go is yours to edit; it's compiled against the trusted solution_test.go.
Run
go test -v ./challenges/binary-search/go/
Sign in to submit your solution.