Https://discuss.codechef.com/t/print-the-possible-decoding-of-a-given-digit-sequence/32332/2

Continuing the discussion from Print the Possible Decoding of a given Digit Sequence:

#import java.util.*;
public class test
{
public static void main(String []args)
{
String s=“”;
int n,d;
while(n>0)
{
d=n%10;
s=s+(char)(d+64);//char of 65 to 90 is A-Z
n=n/10;
}
System.out.println(s);
}
}

I have asked the question to print all the possible decodings.
For 123 it should print
“ABC”
“LC”
“AW”

Search on Google… It’s present on geeks for geeks

On GeeksForGeeks it is only the count of decodings,
I wanted to print all the possible decodings.

anyone pls do help it is an amazon interview question and so i need help at urgency

static int countDecoding(String digits, int n)
{
if (n == 0 || n == 1)
return 1;

    if (digits.charAt(0) == '0')
        return 0;

    int count = 0;

    if (digits.charAt(n - 1) > '0')
        count = countDecoding(digits, n - 1);

    if (digits.charAt(n - 2) == '1'
        || (digits.charAt(n - 2) == '2'
            && digits.charAt(n - 1) < '7'))
        count += countDecoding(digits, n - 2);

    return count;
}

static int messageDecoding(String message)
{
    int n = message.length();
    
    if (n == 0 || (n == 1 && message.charAt(0) == '0'))
        return 0;
    return countDecoding(message, n);
}