Problem
Ask
Submissions

Problem: Binary Search

Medium
30 min
Explore how to implement and adapt binary search for finding target values in sorted integer arrays. Understand the problem constraints, recognize unique elements, and develop coding solutions that return the correct index or -1 when the target is missing. This lesson builds skills to solve diverse search problems using modified binary search techniques.

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 how to implement and adapt binary search for finding target values in sorted integer arrays. Understand the problem constraints, recognize unique elements, and develop coding solutions that return the correct index or -1 when the target is missing. This lesson builds skills to solve diverse search problems using modified binary search techniques.

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.