Your question is Array Index Sum Target. 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.
John Deere Operations Center receives integer telemetry readings from connected equipment. Given an array of readings and a target sum, return the indices of the first pair whose values add up to the target.
Scan the array from left to right. A pair is considered the first finding when its second index is encountered first; if multiple earlier values can pair with that element, use the smallest first index. Return the pair of indices in ascending order. Do not reuse the same array element. If no pair exists, return an empty list.
Implement find_first_pair(nums, target), where nums is a list of integers and target is an integer. Return a two-element list [i, j] such that i < j and nums[i] + nums[j] == target, or return [] when no valid pair exists.
def find_first_pair(nums, target):