All Unique Two-Sum Pairs
Problem statement
Given an integer array nums and an integer target, return every distinct pair of values whose sum equals target.
Write each pair as [a,b] with a <= b. A pair [x,x] is valid only when x occurs at least twice. Return the pairs in increasing lexicographic order with no duplicates.
Function
allUniquePairs(nums: int[], target: int) → int[][]Examples
Example 1
nums = [1,2,3,2,4,0]target = 4return = [[0,4],[1,3],[2,2]]The three distinct value pairs sum to 4. Two copies of 2 make [2,2] valid.
Example 2
nums = [1,1,1]target = 2return = [[1,1]]Repeated index choices do not create additional value-pair results.
Constraints
0 <= nums.length <= 100000-10^9 <= nums[i], target <= 10^9