Basic Binary Search

Easy
Problem Statement

Given a sorted array of integers and a target value, return the index of the target if it is present in the array. If it is not present, return -1.

Constraints

  • Array is sorted in ascending order
  • Time Complexity: O(log N)
  • Space Complexity: O(1)
Solution