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.
Be the first one to answer
Add answer anonymously...
Borderfree Mern Stack Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter