Your question is Two-Sum Array Function. 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.
Within an Auto-Owners Insurance claims review workflow, identify two transaction values whose combined amount matches a specified target. Given an unsorted array of integers, return the indices of the two distinct elements whose values add up to the target.
You may assume that each valid input contains exactly one solution. Return the indices in the order they are discovered, and do not use the same array element twice. If the input violates the guarantee, return an empty list.
Implement two_sum(nums, target).
nums, an array of integers, and target, an integer.[i, j] such that nums[i] + nums[j] == target and i != j.[] if no qualifying pair exists.Use a solution that runs in linear time on average. A brute-force pair search is correct but does not meet the preferred efficiency for larger claim batches.
def two_sum(nums, target):