 0

Find All Subsets

Difficulty: EASY
Avg. time to solve
15 min
Success Rate
90%

Problem Statement

Note: You can return the subsets in any order, you don’t have to specifically sort them.

Input Format :
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows

The first line of each test case contains a single integers ‘N’ denoting the length of the array.

The second line of each test case contains ‘N’ integers denoting the array elements.
Output Format :
For each test case print each subset in a separate line.

Output for each test case will be printed in a separate line.
Note :
You are not required to print anything; it has already been taken care of. Just implement the function.
Constraints :
1 <= T <= 10
1 <= N <= 10
10^-9 <= arr[i] <= 10^9

Time limit: 1 sec
2
3
1 2 3
1
10
1
1 2
1 2 3
1 3
2
2 3
3
10
Explanation Of Sample Output 1 :
For test case 1 :
Total 7 possible subsets can be formed: {1}, {1,2}, {1,2,3}, {1,3}, {2}, {2,3}, {3}

For test case 2 :
Only a single subset {10} is possible for the given input array.
2
2
1 2
3
1 2 3
Sample Output 2 :
1
1 2
2
1
1 2
1 2 3
1 3
2
2 3
3   Console