Why my code is not accepted? Although i have used a different approach but the answer is same, only the sequence is different.
Recursion_Subsequences
@56amrut.bhokardankar
output should be exactly same as required otherwise it should not pass the testcase
So what should be the approach?Do i need to use an entierly different approach or some changes can be made in the same
use this approach it is very easy and understandable
#include<iostream>
using namespace std;
int cnt=0;
void Subsequence(char str[100],int i,char out[100],int j){
// Base CASe:
if(str[i]=='\0'){
out[j]='\0';
cout<<out<<" ";
cnt++;
return;
}
//Recursive CAse:
/// don't consider the char
Subsequence(str,i+1,out,j);
/// consider the char
out[j]=str[i];
Subsequence(str,i+1,out,j+1);
}
int main(){
char str[100],out[100];
cin>>str;
Subsequence(str,0,out,0);
cout<<"\n"<<cnt<<endl;
return 0;
}
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course