Your question is Binary Search for Target Index. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
IDeaS G3 RMS can provide sorted forecast values for analysis. Given a sorted list of integers and a target integer, return the index of the target's first occurrence. Return -1 if the target is not present.
Your solution should use binary search rather than scanning every element.
Implement search_first(nums, target).
nums, a non-decreasing list of integers, and target, an integer.i such that nums[i] == target, or -1 when no such index exists.def search_first(nums, target):