MCPcopy Create free account
hub / github.com/SAKET-SK/Programming-Aptitude-Interview-Prep / func

Method func

Cognizant/Que 20/Solution.java:7–29  ·  view source on GitHub ↗
(int i, String res)

Source from the content-addressed store, hash-verified

5 static ArrayList < String > list = new ArrayList < String > ();
6
7 public static void func (int i, String res)
8 {
9 if (i == str.length ())
10 {
11 list.add (res);
12 return;
13 }
14 if (i > str.length ())
15 return;
16 if(str.charAt (i) == '0')
17 return;
18 char ch = (char) ('a' + (str.charAt (i) - '1'));
19
20 func (i + 1, res + ch);
21
22 if (i != str.length () - 1)
23 if (str.charAt (i) < '3' && str.charAt (i + 1) < '7')
24 {
25 int a = (str.charAt (i) - '1' + 1), b = (str.charAt (i + 1) - '0');
26 ch = (char) ('a' + (10 * a + b - 1));
27 func (i + 2, res + ch);
28 }
29 }
30
31 public static void main (String[]args)
32 {

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected