57: Binary search

Given a sorted array and target value, return a target value position, return -1 if the target value does not exist

 

Example 1

Input:   array = [0, 1, 3, 4], target = 3

Output: 2

Example 2

Input:   array = [1, 2, 4], target = 5

Output: -1
Difficulty:Easy
Topic:Binary Search
Problem #:57