Tricky permutation question


it is printing same combination multiple times.Pl tell how to resiolve it

Hello @ayush15goel,

You have to apply a logic before performing the swapping logic in the loop to check if you should perform swapping or not:

  1. if a[j] has already occurred between index i to j-1, then you should not swap as this will cause duplicate copy.

  2. Even if you will successfully implement this logic, your code would not work for all test cases as it would not print strings in sorted order
    Example: ABCC

Try hard to remove all the logical errors.
Hope, this would help.
If you still face problem, feel free to ask.
Give a like, if you are satisfied.

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.