Given an integer array nums and an integer target, return the indices of two distinct elements whose values add up to target. Exactly one valid pair exists. Return the lower index first.
Input / output
nums: integer[], target: integer[leftIndex, rightIndex]Examples
nums = [2, 7, 11, 15], target = 9 returns [0, 1] because 2 + 7 = 9.nums = [3, 2, 4], target = 6 returns [1, 2].Constraints
2 <= nums.length <= 10,000-1,000,000 <= nums[i], target <= 1,000,000Follow-up Can you solve it in linear time with a single pass and explain the memory tradeoff?