This approach has the same space and time complexity as the permutations question.
Because remember, in the problem statement it was mentioned that there may be duplicates.
All right.
So if there are no duplicates we would have n factorial permutations.
And as we've discussed avoiding the or ignoring the overlaps, we are calling the perm function n times
for each permutation.
And inside each call we are just doing constant time operations.
So that is why the time complexity is of the order of n into n factorial, and the space complexity
is of the order of n, because n is the maximum depth of the recursion tree.
So space is being used for the recursive call stack.