Solution: Binary Search

Let's solve the Binary Search problem using the Modified Binary Search pattern.

Statement

We are given an array of integers, nums, sorted in ascending order, and an integer value, target. If the target exists in the array, return its index. If the target does not exist, return -1.

Constraints:

  • 11\leq nums.length \leq 10310^3 ...

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.