Find All Subsets
You are given an array ‘arr’ of ‘N’ distinct integers. Your task is to find all the non-empty subsets of the array.
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
CodingNinjas
author
2y
Power Set Using Bit-Masking
One of the standard and useful method of finding the power set is through bit-masking.
Consider a number with N-bits in its binary representation, if we consider that the st...read more
CodingNinjas
author
2y
Backtracking
Each element has 2 choices, it can either be included or excluded.
Using backtracking we can create all the possible subsets, we can add the current element to the temporary array and make...read more
Help your peers!
Add answer anonymously...
Top OpenText Technologies Full Stack Engineer interview questions & answers
Popular interview questions of Full Stack Engineer
>
OpenText Technologies Full Stack Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app