Skip to content

Practice Decode Ways II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#639
LeetCode Problem

Decode Ways II

Problem Statement

Decode s using A = 1, B = 2, through Z = 26. Divide the full string into valid one- or two-digit codes; a code cannot start with zero. Each * independently represents any digit from 1 through 9, never zero. Count all resulting valid decodings, including the choices represented by stars, and return the count modulo 10^9 + 7.

Source: Decode Ways II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "*"
Output
9

# Example 2

Input
s = "1*"
Output
18

# Example 3

Input
s = "2*"
Output
15

Constraints

1 <= s.length <= 10^5
s[i] is a digit or '*'.

Related LeetCode Problems

Practice more problems similar to Decode Ways II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.