Loading problem...
Given an array of integers and a target sum value, find and return the indices of two distinct elements in the array whose values sum to the target. You are guaranteed that exactly one valid pair exists in the input, and each element can only be used once in the solution. The order of indices in the returned result does not matter.
nums = [15,42,8,23]
target = 50[1,2]nums[1] + nums[2] = 42 + 8 = 50, so we return [1, 2].
nums = [5,12,7,3,9]
target = 12[0,2]nums[0] + nums[2] = 5 + 7 = 12.
nums = [11,11]
target = 22[0,1]Both elements are 11, and 11 + 11 = 22.
Constraints