Problem
Ask
Submissions

Problem: Binary Search

Medium
30 min
Explore the binary search algorithm to efficiently locate target values in sorted integer arrays. This lesson guides you through understanding problem constraints and applying the method to return the correct index or -1 if the target is absent.

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

  • 104-10^4\leq nums[i] , target \leq 10410^4

  • All integers in nums are unique.

  • nums is sorted in ascending order.

Problem
Ask
Submissions

Problem: Binary Search

Medium
30 min
Explore the binary search algorithm to efficiently locate target values in sorted integer arrays. This lesson guides you through understanding problem constraints and applying the method to return the correct index or -1 if the target is absent.

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

  • 104-10^4\leq nums[i] , target \leq 10410^4

  • All integers in nums are unique.

  • nums is sorted in ascending order.