#C9701. Find Unique Pairs with Target Sum
Find Unique Pairs with Target Sum
Find Unique Pairs with Target Sum
Given an array A of integers and a target integer T, your task is to find all unique pairs (a, b) from the array such that:
\(a+b=T\)
Each pair must be sorted in ascending order (i.e. \(a \le b\)). The overall list of pairs should be sorted in lexicographical order, and duplicate pairs are not allowed even if the numbers appear multiple times in the array.
You must read input from standard input and write the result to standard output.
inputFormat
The input consists of two lines. The first line contains two integers separated by a space: N (the number of elements in the array) and T (the target sum). The second line contains N integers, separated by spaces, representing the elements of the array.
outputFormat
Output a single line representing a list of pairs in the following format: each pair is enclosed in square brackets and the entire output is enclosed in square brackets. For example, if the valid pairs are [-1, 8], [2, 5], and [3, 4], then the output should be:
[[-1,8],[2,5],[3,4]]
If no valid pair exists, output []## sample
9 7
2 4 3 5 6 -1 7 8 3
[[-1,8],[2,5],[3,4]]