Problem
Search a sorted array and return the index of the target or -1.
Example 1
Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4
Constraints
- 1 <= nums.length <= 10^4
Notes
- Focus on the underlying binary search pattern.
- Write the cleanest correct solution before optimizing further.
- Hidden tests cover larger edge cases than the visible examples.