1
00:00:01,010 --> 00:00:03,410
Hi everyone, let's do this question.

2
00:00:03,410 --> 00:00:08,900
Given an integer array of unique elements, return all possible subsets.

3
00:00:08,900 --> 00:00:09,770
The power set.

4
00:00:09,770 --> 00:00:11,300
This is called the power set.

5
00:00:11,300 --> 00:00:15,290
The solution set must not contain duplicate subsets.

6
00:00:15,290 --> 00:00:17,420
Return the solution in any order.

7
00:00:17,420 --> 00:00:18,860
So this is the question.

8
00:00:18,860 --> 00:00:20,360
Now let's try to understand this.

9
00:00:20,390 --> 00:00:24,080
We have to return all the possible subsets of the given array.

10
00:00:24,080 --> 00:00:26,180
So that is what is mentioned in the question.

11
00:00:26,180 --> 00:00:27,980
And that is called the power set.

12
00:00:28,010 --> 00:00:32,930
Now for example, if the array which is given to us is one comma seven, this one over here, then the

13
00:00:32,930 --> 00:00:35,330
power set will be all the possible subsets.

14
00:00:35,330 --> 00:00:38,360
So we have an empty array over here which is a subset.

15
00:00:38,360 --> 00:00:41,000
Then we have only one only seven.

16
00:00:41,000 --> 00:00:42,410
And then we have one and seven.

17
00:00:42,410 --> 00:00:49,400
So you can see we have four subsets which are possible and the set of all the possible subsets.

18
00:00:49,400 --> 00:00:51,590
This over here is called the power set.

19
00:00:51,590 --> 00:00:53,030
So again that's the question.

20
00:00:53,030 --> 00:00:54,050
We will be given an array.

21
00:00:54,050 --> 00:00:56,630
And we have to return the power set of that array.

22
00:00:56,630 --> 00:01:00,410
Now over here also notice that we can return the solution in any order.

23
00:01:00,410 --> 00:01:04,040
So that means that we can either write one 7 or 7 comma one.

24
00:01:04,040 --> 00:01:05,300
So it does not matter.

25
00:01:05,300 --> 00:01:08,330
So the order does not matter when we create the power set.

26
00:01:08,330 --> 00:01:08,960
All right.

27
00:01:08,990 --> 00:01:14,660
Now let's go ahead and try to understand this better by writing a few test cases.

28
00:01:14,660 --> 00:01:19,850
Now remember in the interview try to talk to the interviewer and you can ask the interviewer whether

29
00:01:19,850 --> 00:01:24,230
he or she is okay, that whether you both could come up with the test cases together.

30
00:01:24,230 --> 00:01:27,110
So that will ensure that you have a thorough understanding of the question.

31
00:01:27,110 --> 00:01:28,520
Now let's proceed.

32
00:01:28,520 --> 00:01:32,060
Let's say the array which is given to us is one, two and three.

33
00:01:32,060 --> 00:01:37,070
Now let's go ahead and write the power set or all the subsets of this possible array.

34
00:01:37,070 --> 00:01:42,590
Now there is a a subset where the array is empty right.

35
00:01:42,590 --> 00:01:45,380
And then I could have arrays of length one.

36
00:01:45,380 --> 00:01:48,680
So I just take one I just take two and I just take three.

37
00:01:48,680 --> 00:01:51,590
Now I can have subsets where I take two elements right.

38
00:01:51,590 --> 00:01:54,800
So I could take one and two, one and 3 or 2 and three.

39
00:01:54,800 --> 00:01:58,760
And finally I can have a subset where I have all the three elements.

40
00:01:58,760 --> 00:02:00,890
So I can have one, two and three also.

41
00:02:00,890 --> 00:02:06,980
So these are the eight possible subsets which I can have when the array which is given to me is one,

42
00:02:06,980 --> 00:02:07,760
two and three.

43
00:02:07,760 --> 00:02:08,510
All right.

44
00:02:08,870 --> 00:02:10,580
Now let's take a few more cases.

45
00:02:10,580 --> 00:02:13,550
What if I'm given an array with only one element.

46
00:02:13,550 --> 00:02:14,480
Let's say nine.

47
00:02:14,480 --> 00:02:18,290
In this case I can have a subset which is an empty array.

48
00:02:18,290 --> 00:02:20,960
And I can have a subset which has only nine.

49
00:02:20,960 --> 00:02:23,210
And what if I'm given an empty array?

50
00:02:23,210 --> 00:02:26,690
Then the power set will have only one element right?

51
00:02:26,690 --> 00:02:28,790
And that itself will be an empty array.

52
00:02:28,790 --> 00:02:33,860
So this is a few test cases that gives us a good understanding of the question.

53
00:02:33,860 --> 00:02:38,870
Now in the next video, let's try to think through how we can solve this question.
