For nums = [-1,0,3,5,9,12] and target = 9, what index is returned?
Practice this question from Binary Search - Classic search Pattern Practice Quiz, with options and an explanation.
Question
For nums = [-1,0,3,5,9,12] and target = 9, what index is returned?
Option A
2
Option B
3
Option C — Correct answer
4
Option D
-1
Explanation
The target 9 is found at index 4.