Secret Message Decoding Problem
Ninja encountered an encoded secret message where each character from 'A' to 'Z' is mapped to a numeric value (A = 1, B = 2, ..., Z = 26). Given a numeric sequence (SEQ) derived from such encoding, determine how many ways the sequence can be decoded back into a valid string.
Input:
The first line contains an integer T representing the number of test cases.
Each test case consists of a single line with a digit sequence.
Output:
For each test case, output the number of ways to decode the provided digit sequence in a separate line.
Example:
Input:
1
121
Output:
3
Explanation:
Three possible decodings for sequence '121' are 'ABA', 'LA', and 'AU'.
Constraints:
- 1 <= T <= 10
- 1 <= N <= 105
- 0 <= SEQ[i] <= 9
Note:
Input sequence will always have at least 1 valid decoding.
Return the answer modulo 10^9 + 7.
You are not required to print anything as this is handled by the framework. Implement the function logic.

AnswerBot
4mo
The problem involves decoding a numeric sequence back into a valid string based on a given mapping of characters to numeric values.
Use dynamic programming to keep track of the number of ways to decode...read more
Help your peers!
Add answer anonymously...
Nagarro Senior Software Engineer interview questions & answers
A Senior Software Engineer was asked 6mo agoQ. What are functional interfaces in programming?
A Senior Software Engineer was asked 8mo agoQ. What is the Node.js event loop and how does it work?
A Senior Software Engineer was asked 10mo agoQ. Write a debounce function.
Popular interview questions of Senior Software Engineer
A Senior Software Engineer was asked 6mo agoQ1. What are functional interfaces in programming?
A Senior Software Engineer was asked 8mo agoQ2. What is the Node.js event loop and how does it work?
A Senior Software Engineer was asked 10mo agoQ3. Write a debounce function.
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

