209. All Subsets
MediumBacktrackingBitmask
Print all subsets of the distinct values, one per line. Each subset lists its values in increasing order; subsets are printed in lexicographic order of these lists, starting with the empty subset printed as -.
Input format
Line 1: n Line 2: n distinct integers
Output format
2ⁿ lines.
Example 1
Input
3 1 2 3
Output
- 1 1 2 1 2 3 1 3 2 2 3 3
Example 2
Input
1 5
Output
- 5
Constraints
1 ≤ n ≤ 12
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…