Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

Given the mobile numeric keypad. You can only press buttons that are up, left, right, or down to the current button. You are not allowed to press bottom row corner buttons (i.e. * and # ). Given a number **N**, the task is to find out the number of possible numbers of the given length.

**Example 1:**

**Input**: 1
**Output:** 10
**Explanation**: Number of possible numbers
would be 10 (0, 1, 2, 3, …., 9)

**Input: **N = 2
**Output: **36
**Explanation**: Possible numbers: 00, 08, 11,
12, 14, 22, 21, 23, 25 and so on.
If we start with 0, valid numbers
will be 00, 08 (count: 2)
If we start with 1, valid numbers
will be 11, 12, 14 (count: 3)
If we start with 2, valid numbers
will be 22, 21, 23,25 (count: 4)
If we start with 3, valid numbers
will be 33, 32, 36 (count: 3)
If we start with 4, valid numbers
will be 44,41,45,47 (count: 4)
If we start with 5, valid numbers
will be 55,54,52,56,58 (count: 5)
and so on..

**Your Task: **

You don't need to read input or print anything. Complete the function ** getCount() **which takes

1 ≤

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Mobile numeric keypad

...

Here is some troubleshooting advice:

- Reset the IDE using the second button on the top right corner.
- Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
- Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
- You can access the hints to get an idea about what is expected of you as well as the final solution code.
- You can view the solutions submitted by other users from the submission tab.

Here is some troubleshooting advice for contest problems

- Make sure you are not using ad-blockers.
- Disable browser extensions.
- We recommend using latest version of your browser for best experience.
- Avoid using static/global variables in coding problems as your code is tested against multiple test cases and these tend to retain their previous values.
- Passing the Sample/Custom Test cases in coding problems does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.