#C13094. Unique Combinations
Unique Combinations
Unique Combinations
Given an array of distinct integers and an integer (k), your task is to generate all possible unique combinations of (k) numbers from the array. The output must list the combinations in lexicographical (sorted) order.
Note: If (k) is greater than the number of elements in the array, output nothing.
inputFormat
Input is read from standard input (stdin) and consists of three parts:
1. An integer (n), the number of elements in the array.
2. A line containing (n) space-separated integers.
3. An integer (k) representing the number of elements to choose for each combination.
outputFormat
Output the resulting combinations to standard output (stdout). Each combination should be printed on a separate line with its elements separated by a single space. Combinations must appear in lexicographical order. If there is no valid combination, output nothing.## sample
5
1 2 3 4 5
2
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
</p>