Decode Ways Problem Statement

Given a string strNum that represents a number, the task is to determine the number of ways to decode it using the following encoding: 'A' - 1, 'B' - 2, ..., 'Z' - 26.

Input:

The first line of input includes an integer 'T', indicating the number of test cases.
The following 'T' lines each contain a single string strNum.

Output:

For each test case, output the number of ways to decode strNum.

Example:

Example case: For strNum = '226', there are 3 possible decodings:
For instance: 'BZ' (2-26), 'BBF' (2-2-6), 'VF' (22-6).

Constraints:

  • 1 ≤ T ≤ 50
  • 1 ≤ N ≤ 10^4
  • Time Limit: 1 second

Note:

1. The answer should be returned modulo 10^9+7 due to potentially large numbers of decode ways.
2. Your task is to implement the function to solve the problem; output handling has been managed.
AnswerBot
4mo

The task is to determine the number of ways to decode a given number string using a specific encoding.

  • Iterate through the string and use dynamic programming to calculate the number of ways to decode a...read more

Help your peers!
Select
Add answer anonymously...
Mern Stack Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits