#include <bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<set>
using namespace std;
bool comparator(string a, string b){
return a>b;
}
vector<string>s;
void printSubSeqRec(string str, int n, int& count,int index = -1, string curr = "")
{
// base case
if (index == n)
return;
if (!curr.empty()) {
// cout << curr << " ";
s.push_back(curr);
count++;
}
for (int i = index + 1; i < n; i++) {
curr += str[i];
printSubSeqRec(str, n,count, i, curr);
// backtracking
curr = curr.erase(curr.size() - 1);
}
return;
}
// Generates power set in lexicographic
// order.
void printSubSeq(string str)
{
int count=0;
printSubSeqRec(str, str.size(),count);
// cout<<count+1;
}
// Driver code
int main()
{
string str;
cin>>str;
printSubSeq(str);
sort(s.begin(),s.end(),comparator);
for(auto x:s){
cout<<x<<" ";
}
cout<<endl<<s.size()+1;
return 0;
}
Aint passing any case
hey, is there anything else??
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.