No same permutation

Can you please provide solution to this problem in java. I have tried my best to remove TLE. It does not work.

Also, how can this problem be solved without using Set or HashMap

@vkth
To avoid TLE, you have to avoid generating all the permutations. You will get TLE if you generate all the permuations.
I am attaching a code snippet of the function to generate unique permutation.

Thank you. It worked out. :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.