Two Sum with Distinct Pairs
Problem statement
Return every distinct pair of values from nums whose sum is target.
Use two different array positions. Within each pair return the smaller value first, and sort the returned pairs lexicographically. Duplicate occurrences must not duplicate a value pair.
Function
twoSumDistinctPairs(nums: int[], target: int) → int[][]Examples
Example 1
nums = [1,1,2,2,3,4]target = 4return = [[1,3],[2,2]]Both value pairs exist; repeated positions do not duplicate them.
Example 2
nums = [0,-1,2,-3,1]target = -2return = [[-3,1]]Only -3 and 1 sum to -2.
Constraints
0 <= nums.length <= 10^5.- Values and target are 32-bit signed integers.