Mike and Mobile Keypad Problem
Mike, a young math enthusiast, is playing with his mom’s mobile phone, which has a keypad with 12 buttons (10 digits: 0-9, and 2 special characters: ‘*’ and ‘#’). His challenge is to find out how many different numbers he can generate by pressing exactly 'N' buttons. He follows these rules:
1. Mike only presses buttons with digits (0-9), never the ‘*’ or ‘#’.
2. The next button press must either be the same button or an adjacent button.
3. Initially, he can start pressing any button except ‘*’ or ‘#’.
Your task is to help Mike solve this problem, and due to potentially large results, output the answer modulo 10^9 + 7.
Input:
The first line of the input is an integer 'T', indicating the number of test cases.
Each of the next 'T' lines contains an integer N, the number of buttons to press.
Output:
For each test case, output the number of distinct numbers that can be formed by pressing exactly 'N' buttons on the keypad. Print each result on a new line.
Example:
Input:
2
1
2
Output:
10
36
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 5 * 104
- Time Limit: 1 second
Note:
You do not need to print anything; the function implementation will handle this itself.

AnswerBot
4mo
Calculate the number of distinct numbers that can be formed by pressing 'N' buttons on a mobile keypad following specific rules.
Use dynamic programming to keep track of the number of distinct numbers ...read more
Help your peers!
Add answer anonymously...
Amazon Software Developer interview questions & answers
A Software Developer was asked 1mo agoQ. What is HTML?
A Software Developer was asked 1mo agoQ. What is MySQL?
A Software Developer was asked 3mo agoQ. What is the system design for the cart feature in an e-commerce website?
Popular interview questions of Software Developer
A Software Developer was asked 1mo agoQ1. What is HTML?
A Software Developer was asked 1mo agoQ2. What is MySQL?
A Software Developer was asked 3mo agoQ3. What is the system design for the cart feature in an e-commerce website?
Top HR questions asked in Amazon Software Developer
A Software Developer was asked 1mo agoQ1. Tell me about a time you had to get to the root cause of a problem
A Software Developer was asked 5mo agoQ2. What are the short-term and long-term goals for the team or organization?
A Software Developer was asked 5mo agoQ3. Why do you want to work at Amazon?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

