#K53147. Combination Sum II

    ID: 29467 Type: Default 1000ms 256MiB

Combination Sum II

Combination Sum II

Given an array of integers (nums) and a target integer (target), find all unique combinations in (nums) whose sum equals (target). Each number in (nums) may only be used once in each combination, and duplicate combinations are not allowed.

Read input from standard input (stdin) and print the result to standard output (stdout) as a list of lists. Each individual combination should be in non-decreasing order.

inputFormat

The first line contains the target integer (target). The second line contains a list of integers separated by spaces representing the array (nums).

outputFormat

Output the list of unique combinations (as a list of lists) that sum up to (target). The format should exactly match the example outputs, with each combination enclosed in square brackets.## sample

8
10 1 2 7 6 1 5
[[1, 1, 6], [1, 2, 5], [1, 7], [2, 6]]