…
Problem⌘ K
Binary Search
Given a sorted array of distinct integers and a target value, return the index of the target if it exists. Otherwise return -1.
Example
Input nums = [-1,0,3,5,9,12], target = 9
Output 4
Constraints
• 1 ≤ nums.length ≤ 10⁴.• All values in nums are distinct and sorted ascending.
Think about
Try a first approach in the editor. Copilot reviews your actual code and asks one focused question when it finds a gap.
Test resultsReady
$ Type your approach, then run the sample tests.
LIVE AI REVIEW · WAITING
Start typing or paste your attempt here.
—
—