Why does it shows WA, even when all the subsequences are printed as mentioned?

//#include <bits/stdc++.h>

using namespace std;

//#define ll long long int

void print(string str,int len,string temp,int &val){

if(len == 0){

	cout<<temp<<" ";

	val++;

	return;

}

print(str,len-1,temp,val);

print(str,len-1,temp+string(1,str[len-1]),val);

}

int main(){

string s;

cin>>s;

int val = 0;

print(s,s.length(),"",val);

cout<<endl;

cout<<val<<endl;

return 0;

}

hello @Mr_robot
image
u can not change the ordering of the character.

for example->
here for abcd a comes before b , c ,d
so in any subsequence it should come in same relative order only.

recurrencr for this problem is simple.
ignore ith character in ur solution
or add ith character in ur solution

Ok . Got you.
Thanks.