Permutation of String letters: How to remove repeated permutations?

前端 未结 10 2286
遇见更好的自我
遇见更好的自我 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 08:55

    Algorithm steps:

    1. Store the given string into temporary string say "temp"
    2. Remove duplicates from temp string
    3. And finally call "void permute(char *a, int i, int n)" function to print all permutation of given string without duplicates

    I think, this is best and efficient solution.

提交回复
热议问题