Mobile Numeric Keypad Problem\\n

In this problem, a Numeric mobile keypad is given. We can only press top, bottom, right and left buttons of the current button, diagonal keys are not Allowed. We also cannot press the * and # buttons in the keypad.

A digit is given, we have to find the number of possible numbers of given digits can be formed, using the keypad, maintaining given rules.

Input and Output

Input:
Digit count. Say 3 digit numbers.
Output:
Number of possible 3 digit numbers, that can be formed with the given conditions. Here the answer is 138.

Algorithm

getCount(n)

Input: number of digits n.
Output: Possible ways to type n digit numbers in a mobile keypad.

Begin
   if n 

Example

#include 
using namespace std;

char keypad[4][3] = {
   {'1','2','3'},
   {'4','5','6'},
   {'7','8','9'},
   {'*','0','#'}
};

int getCount(int n) {
   if(keypad == NULL || n = 0 && rowMove =0 && colMove > n;
   cout 

Output

Number of digits: 3
Possible Combinations: 138
Updated on: 2020-06-17T07:31:04+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements