I have tried a approach of print all the subsequences of a stirng using recursion but not able to implement this how can i print all the subsequences of a string in lexicographical order. INPUT:- abc OUTPUT: a b c ab ac bc abc
I have tried this approach to print all the subsequences of a string:
void print(string s,string temp)
{
if(s.empty()){
cout<<temp<<endl;
return;
}
print(s.substr(1),temp + s[0]);
print(s.substr(1),temp);
}