only 3 test cases are passing
Tricky permutation problem
Hi @shampblocks,
try storing the result first in a set. And then print all the strings at the and.
In ur present code, all strings are not getting printed lexographically.
Hope dis helps
i have checked it is printing lexographically can you give an example of test case in which it is failing so that i can get the idea of what i am doing wrong??
oh yes it is not printing lexographically can you explain how to use set??
@shampblocks,
declare a set s globally or locally(depends on u).
insert ur final string in it using s.insert(string)
and after u exits ur compute permutation function,
output the set using
for(auto i:s ){
cout<<i<<endl;
}
Hope dis helps.
I have used vector of strings and sorted it …after coming back from function call it worked I want to know what is the benefit of using set??
@shampblocks,
use of set is better here since set not only store elements in sorted order but also removes duplicate elements from the list.
insertion in set take logn time. so worst case time complexity in both cases is nlogn(vector and set).
So, use of set is more justified.
Hope dis helps.
So to remove duplicates we prefer sets?? Set will take care of it…
But according to my code my code will give elements without duplicate so there is no need for taking care of it only aim was sorting…
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.