#C3415. Find Unique Integer Pairs with Given Sum
Find Unique Integer Pairs with Given Sum
Find Unique Integer Pairs with Given Sum
You are given a list of integers and a target integer \(k\). Your task is to find all unique pairs of numbers in the list that add up to \(k\). Two pairs are considered the same if they consist of the same two numbers, regardless of order.
Example:
Input: [1, 2, 3, 4, 5, 6], k = 7 Output: [(1, 6), (2, 5), (3, 4)]
Note that each pair is represented as \((a, b)\), where \(a \leq b\). The output list should be in sorted order based on the natural tuple order.
inputFormat
The first line of input contains two integers \(n\) and \(k\) where \(n\) is the number of elements in the list and \(k\) is the target sum. The second line contains \(n\) space-separated integers.
For example:
6 7 1 2 3 4 5 6
outputFormat
Print the list of unique pairs in the following format:
[(a1, b1), (a2, b2), ...]
If there are no such pairs, print an empty list: []
.
6 7
1 2 3 4 5 6
[(1, 6), (2, 5), (3, 4)]