https://ide.codingblocks.com/s/175327 it passes the given input but failed in all the test cases.
Dictionary Larger order
Hey, just a small problem ,
since the changes are made in the original string after the swapping is done , u have to swap back ie backtrack the changes, else we get the same permutation os string which we have already recieved in previous steps, do refer to the video of string permutation
for(int j = i;s[j]!=’\0’;j++){
swap(s[j],s[i]);
dictionary(s,output,i+1);
swap(s[j] , s[i]); // this line has to be added
}
Also use a vector to store the string because the question demands The output strings must be lexicographically sorted.
So sort it then only print string greater than current i/p string.
1 Like