MCPcopy Create free account
hub / github.com/Manvityagi/PW-Skills-Java-Course-Codes / Main

Class Main

Lecture 36 - Recursion 9/src/Main.java:3–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import java.util.*;
2
3public class Main {
4 static void combination(String dig, String[] kp, String res) {
5 if (dig.length() == 0) {
6 System.out.print(res + " ");
7 return;
8 }
9 int currNum = dig.charAt(0) - '0';
10 String currChoices = kp[currNum];
11 for (int j = 0; j < currChoices.length(); j++) {
12 combination(dig.substring(1), kp, res + currChoices.charAt(j));
13 }
14 }
15
16 public static void main(String[] args) {
17 Scanner sc = new Scanner(System.in);
18 String s = sc.nextLine();
19 String[] keypad = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqr", "stuv", "wxyz"};
20 combination(s, keypad, "");
21 }
22}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected