Mapped Strings help needed

The input will be a number which i divide by 10 and push them into a vector and sort the vector and send it to the function. The function actually first calls the recursion to not add the adjacent values and then it adds it in the second call .
Check for yourself :

Hello @sonishivam417,

Your program is failing for 0
Example:

input.push_back(1);
input.push_back(2);
input.push_back(0);
input.push_back(3); 

The output is coming:

AB C
ABC
ATC
L C
LC

You are mapping 0 with space which is wrong.
You have to consider:
[1,2,3]
[1,20,3]
[12,3]
only

Hope, this would help.

void printpermutations(vector &input,vector &out,int i,int n) { if(i>=n) { for(int i=0;i<out.size();i++) { if(out[i]==0) continue; cout<<alphabets[out[i]-1]; } //out.pop_back(); cout<<endl; return; } out.push_back(input[i]); printpermutations(input,out,i+1,n); out.pop_back(); int sum=input[i]*10+input[i+1]; if(sum<=26 && i<n-1 && input[i]!=0) { out.push_back(sum); printpermutations(input,out,i+2,n); out.pop_back(); } return; } int main() { vector out; vector input; input.push_back(1); input.push_back(2); input.push_back(0); input.push_back(3); printpermutations(input,out,0,4); return 0; }

https://ide.codingblocks.com/s/104091 could you check this time

Seems logically correct to me.

You can test it here.
Don’t forget to change the input format according to the question.

Hope, this will help.
Give a like, if you are satisfied.

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.