print all subsets of a string

Solutions on MaxInterview for print all subsets of a string by the best coders in the world

showing results for - "print all subsets of a string"
Dave
02 Oct 2019
1#include <iostream>
2
3using namespace std;
4void solve(string s,string op)
5{
6    if(s.size()==0)
7    {
8        cout<<op<<endl;
9        return;
10    }
11    string op1=op;
12    string op2=op;
13    op2.push_back(s[0]);
14    s.erase(s.begin()+0);
15    solve(s,op1);
16    solve(s,op2);
17}
18int main()
19{
20    string s;
21    cin>>s;
22    string op="";
23    solve(s,op);
24    return 0;
25}
26