code : https://ide.codingblocks.com/s/460096
prob: https://leetcode.com/problems/permutations-ii/submissions/
not working for 4 digits
code : https://ide.codingblocks.com/s/460096
prob: https://leetcode.com/problems/permutations-ii/submissions/
not working for 4 digits
hello @raghav007
try this case->
[1,1,2,2] .
to solve such issue.
sort the input vector .
and then generate the perrmutation without doing any backtracking
I don’ t understand this part
just comment out the second swap statement of ur code,which was responsible for backtracking
please explain why this step is not required in this case
…
becuase the array is sorted.
on sorted array backtracking is not required to generate all permutation. by default the generated sequence will have all permutation
just try to print the permutation and observe the pattern.
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.