How would you optimize a search algorithm for a large dataset at 3Y Health?
Implement locate_targets(data, targets). The input data is a nondecreasing array of integers, and targets is an array of integers to search for. Return an array containing the first index of each target in data, or -1 when a target is absent. Preserve the order of targets, including duplicate queries. The solution should avoid scanning the dataset separately for each target and should scale to millions of data values.
def locate_targets(data, targets):