Smart keypad 1 (error after showing right result)


it is giving right answer but after that it is giving wrong ans , please check.

you are assuming that input can be of 2 digits only but it can be of more than 2 digits…
so approach this problem similar to keypad problem as discussed in recursion

the idea of this ques is same as that of keypad comination…
1)take a string as input
say the string you are taking input as 234

break the string as 2 + 34…call recursion on 34…recursion will do the work on 34 and return you an arraylist of strngs(make your return type of function as ArrayList)…
3)Now just do your self work that is for every character of 2(abc) append it with each String which came as recursion result(from 34’s recursive call)

return the new ArrayList

234 means
2-abc
3-def
4-ghi

in output we will get (34’s recursive call)
dg
dh
di
eg
eh
ei
fg
fh
fi

now append them with a,b and c respectively
to get the desired output
adg,adh…etc

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.