What does it mean by dictionary sort? Please explain the output for the sample input and also give some other example.
Recursion-Dictionary(Problem Statement)
its just like what we search in the dictionary
we actually need to return all the permutations which are smaller than the given string(according to the dictionary order).
My above code is failing on 2 out of 4 test cases.
Please tell what’s wrong.
consider your code for the following input
input: nsit
expected output:
nist
nits
inst
ints
isnt
istn
itns
itsn
your output:
inst
ints
isnt
istn
itns
itsn
nist
nits
I have edited my code. But the code still fails on one test case. Please tell what’s wrong. Is the output for the sample input correct? If Yes, then how?
For “cab” my code gives
bac
bca
abc
acb
But the sample output is -
acb
abc
bca
bac
Hello @isa67719,
- In this question, you need not to swap back elements if they are swapped.
If you would perform second swap operation, then the order will change - There is no need of swapping elements.
3.How are you so sure that there would not be more than 100 characters in the input? Rather use string for input.
Thus, as per the questions requirement, i have modified your code:
Now it’s working perfectly.
Hope, this would help.
Give a like, if you are satisfied.