write a program to print all the combinations of alphabets of length n.Eg: input 2: a b c d e...z aa ab ac ad... zz
Answers
Answered by
0
Answer::-- import static java.lang.Math.*;
private static String getString(int n) {
char[] buf = new char[(int) floor(log(25 * (n + 1)) / log(26))];
for (int i = buf.length - 1; i >= 0; i--) {
n--;
buf[i] = (char) ('A' + n % 26);
n /= 26;
}
return new String(buf);
}
I hope it is helpful for you ♥️♥️♥️
Similar questions