Cascadiq

Binary Search

algorithm · Level 2 · 10 min

Description

Given a sorted ascending array nums and a target target, return the index of target in nums, or -1 if not found.

Requirements

  • Implement a function that takes nums (sorted array) and target.
  • Return the index of target, or -1.

Constraints

- `1 <= nums.length <= 10^4` - `-10^4 <= nums[i], target <= 10^4` - `nums` is sorted in ascending order.

Deliverables

Return the index or -1.

Tags

ArrayBinary Search