import java.util.*;
public class Recursion2 {
public static String[] keybopard = { ".", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
public static void printCombo(String str, int idx, String combination) {
if (idx == str.length()) {
System.out.println(combination);
return;
}
char currChar = str.charAt(idx);
String mapping = keybopard[currChar - '0'];
for (int i = 0; i < mapping.length(); i++) {
printCombo(str, idx + 1, combination + mapping.charAt(i));
}
}
public static void main(String[] args) {
String str = "23";
printCombo(str, 0, "");
}
}
OUTPUT :
dg
dh
di
eg
eh
ei
fg
fh
fi
0 Comments