Skip to content
C

Generate All Subsets

Mediumjavapythonccppjavascript

Given an array of distinct integers, generate every subset (the power set).

Input Format

The first line contains an integer N. The second line contains N space-separated distinct integers.

Output Format

Print 2^N lines, one per subset, in order of the binary mask 0 .. 2^N - 1. For a mask, list the elements at set bit positions in index order, separated by single spaces. The empty subset is printed as an empty line.

Input (stdin)

Output

Run your code to see output here...