Here is a standard function to print the permutations of characters of a string:
void permute(char *a, int i, int n) { int j; if (i == n) printf(\
Another approach could be:
Presort the array.
This will ensure that all duplicate are now consecutive.
So, we just need to see the previous element which we we fixed (and permuted others)
if current element is same as previous, don't permute.