Binary Search

Easy · Binary Search · about 10 minutes

Asked at Microsoft, Apple, Amazon.

nums is sorted ascending and has no repeated values. Report the position of target in it, or -1 when it's missing. The search has to take O(log n) time.

Related guides