Please point out the error in this code. Testcases are failing
Recursion-Dictionary Order (Smaller)
The order in which the values need to be printed are different than required…
You can use the following approach as : void permute_smaller(string input,string output,int i)
{
if(input[i]==’\0’)
{
if(myCompare(input,output))
{
cout<<input<<endl;
}
return;
}
for(int j=i;input[j]!=’\0’;j++)
{
swap(input[i],input[j]);
permute_smaller(input,output,i+1);
}
}
I am printing it in lexicographical order. The output matched with the one given in sample. Please help
Pls share the code if you have edited the code… I will see to it…
Its the same one. I haven’t changed anything