Subsequence generate

#include
using namespace std;
#include

string temp;

void subSequence(string S,int pointer){
if(pointer == S.size()){
cout<<temp<<" ";
return;
}

	subSequence(S,pointer+1);

    temp.push_back(S[pointer]);
    subSequence(S,pointer+1);

return;

}

int main(){
string S;
cin>>S;

subSequence(S,0);
cout<<endl;
 cout<<pow(2,S.size());

}

wrong ouput

hello @khemchandrs,
dont declare ur temp string as global,
pass it along with the function call.
becuase if u delcare it global then u will be appending in the same string and it will be tough to distinguish different subsequence.

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.