I have made this question using set but didn’t got the approach behind editorial, how to solve it without using set in cpp as editorial is in java
Tricky permutation
Hey @Divya_321,
If you are using recursive swapping approach for finding permutation,
Then I you should check if you should perform swapping or not.
Approach:
Permuatation(arr, indx, n){
For i= indx to n{
//Check if you should swap index with I or not
- If arr[i] is not present between index indx and i-1, then do swapping
- else if it is already present, then swapping will lead to duplicate permutation., Thus, don’t perform swapping.
}
}
Refer to the following code for better understanding:
Hope, this would help.
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.