1
00:00:00,320 --> 00:00:07,220
This approach has the same space and time complexity as the permutations question.

2
00:00:07,220 --> 00:00:13,760
Because remember, in the problem statement it was mentioned that there may be duplicates.

3
00:00:13,760 --> 00:00:14,390
All right.

4
00:00:14,390 --> 00:00:18,710
So if there are no duplicates we would have n factorial permutations.

5
00:00:18,710 --> 00:00:26,030
And as we've discussed avoiding the or ignoring the overlaps, we are calling the perm function n times

6
00:00:26,030 --> 00:00:27,650
for each permutation.

7
00:00:27,650 --> 00:00:31,640
And inside each call we are just doing constant time operations.

8
00:00:31,640 --> 00:00:38,690
So that is why the time complexity is of the order of n into n factorial, and the space complexity

9
00:00:38,690 --> 00:00:44,720
is of the order of n, because n is the maximum depth of the recursion tree.

10
00:00:44,720 --> 00:00:49,250
So space is being used for the recursive call stack.
