Permutation of String letters: How to remove repeated permutations?

前端 未结 10 2166
遇见更好的自我
遇见更好的自我 2020-12-25 08:39

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(\         


        
10条回答
  •  生来不讨喜
    2020-12-25 09:07

    It would quite simple if you just think it as a problem where you need to store all the permutations for some future use.

    SO you'll have an array of permuted strings.

    Now think of a new problem, which is also an standard one where you need to remove the duplicates from array.

    I hope that helps.

提交回复
热议问题