Coders Packet

Phone keypad problem in C++

By Vikhyat Yadav

In this problem, we will discuss the combinations of alphabets that occurred by pressing the numbers on the phone keypad, and this problem is solved in C++.


It is often determined that every digit will represent three to four totally different alphabets (apart from zero and 1). Therefore the plan is to make a Recursive function. Then map the quantity with its string of probable alphabets, i.e two with “ABC”, three with “DEF”, four with “GHI” etc. currently the recursive function can attempt all the alphabets, mapped to this digit in the alphabetic order, and again call the recursive function for subsequent digit and can pass away this output string.


1.By Mapping the numbers with its string of probable alphabets, i.e two with “ABC”, three with “DEF” etc.

2.Form a recursive function that takes the subsequent parameters, output string, input array, current index, and counts no. of sequence.

3.If the present index of the input string is null then print the output string.

4.Extract the string at keys[digit] from the Map, wherever the digit is that the input array number.

5.Run a loop to traverse the string from begin to finish.

6.For every index, the recursive function with the output string concatenated with the ith character of the string and also the current_index + 1.

Download Complete Code


No comments yet