Hi everyone, let's do this question.
Given an integer array of unique elements, return all possible subsets.
The power set.
This is called the power set.
The solution set must not contain duplicate subsets.
Return the solution in any order.
So this is the question.
Now let's try to understand this.
We have to return all the possible subsets of the given array.
So that is what is mentioned in the question.
And that is called the power set.
Now for example, if the array which is given to us is one comma seven, this one over here, then the
power set will be all the possible subsets.
So we have an empty array over here which is a subset.
Then we have only one only seven.
And then we have one and seven.
So you can see we have four subsets which are possible and the set of all the possible subsets.
This over here is called the power set.
So again that's the question.
We will be given an array.
And we have to return the power set of that array.
Now over here also notice that we can return the solution in any order.
So that means that we can either write one 7 or 7 comma one.
So it does not matter.
So the order does not matter when we create the power set.
All right.
Now let's go ahead and try to understand this better by writing a few test cases.
Now remember in the interview try to talk to the interviewer and you can ask the interviewer whether
he or she is okay, that whether you both could come up with the test cases together.
So that will ensure that you have a thorough understanding of the question.
Now let's proceed.
Let's say the array which is given to us is one, two and three.
Now let's go ahead and write the power set or all the subsets of this possible array.
Now there is a a subset where the array is empty right.
And then I could have arrays of length one.
So I just take one I just take two and I just take three.
Now I can have subsets where I take two elements right.
So I could take one and two, one and 3 or 2 and three.
And finally I can have a subset where I have all the three elements.
So I can have one, two and three also.
So these are the eight possible subsets which I can have when the array which is given to me is one,
two and three.
All right.
Now let's take a few more cases.
What if I'm given an array with only one element.
Let's say nine.
In this case I can have a subset which is an empty array.
And I can have a subset which has only nine.
And what if I'm given an empty array?
Then the power set will have only one element right?
And that itself will be an empty array.
So this is a few test cases that gives us a good understanding of the question.
Now in the next video, let's try to think through how we can solve this question.