Hi seems like logic is correct please check the code.
Not getting correct answers please check
Thanks I solved it, can you let me know of the approach without using set ?
You can use just recursion to do this.
Let’s say you have a function “printPermutation” which takes in an array and the start index and end index and prints all the permutation by swaping some OR none elements from start to end index.
Now keep each unique element at index 0 and then call the function for the rest of the array.
Print the array when you reach the end.
Let me know if you still need any help
Hi Prashuk got it thanks.
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.