#C11079. Unique Combination Sum II

    ID: 40355 Type: Default 1000ms 256MiB

Unique Combination Sum II

Unique Combination Sum II

You are given a list of integers and a target integer (T). Your task is to find all unique combinations of numbers from the list that sum exactly to (T). Each number in the list may be used at most once in each combination. Note that the list might contain duplicate numbers; however, each combination must be unique (order within a combination does not matter).

For example, given the list [2, 3, 6, 7] and (T = 7), the only valid combination is [7].

inputFormat

The input is given via standard input (stdin). The first line contains an integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers. The third line contains the target integer (T).

outputFormat

Output the list of unique combinations as a Python-style list of lists in a single line. Each inner list represents one valid combination. If no valid combination exists, output an empty list: [].## sample

4
2 3 6 7
7
[[7]]