Hey TA’s , can you tell me how to approach this problem?
Smart keypad-1;
Hey @CODER_JATIN
Algorithm:
- Map the number with its string of probable alphabets, i.e 2 with “abc”, 3 with “def” etc. You can use
string table[] = { " ", ".+@$", "abc", "def", "ghi", "jkl" , "mno", "pqrs" , "tuv", "wxyz" }; - create a recursive function which takes following parameters, output string, number array, current index and length of number array
- If the current index is equal to the length of number array then print the output string.
- Extract the string at digit[current_index] from the Map, where digit is the input number array.
- Run a loop to traverse the string from start to end
- For every index again call the recursive function with the output string concatenated with the ith character of the string and the current_index + 1.
Hey kartik bhaiya, i’d not understood the last step.
Say we had 24
so we first for 2 do a , b ,c
then for 4 we do ad,ae,af,bd,be,bf …
Just do a recursive call for next indexed number
Okay I’m doing . . . .
Okay and suppose , we have input as “123”, then what will be the output?
.ad
.ae
.af
.bd
.be
.bf
.cd
.ce
.cf
+ad
+ae
+af
+bd
+be
+bf
+cd
+ce
+cf
@ad
@ae
@af
@bd
@be
@bf
@cd
@ce
@cf
$ad
$ae
$af
$bd
$be
$bf
$cd
$ce
$cf
Hey @CODER_JATIN
Yup Its correct and also working on hackerblocks .
I am marking this one as resolved if u still have any query feel free to message me personally. 
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.