dp
array of size n + 1
, where n
is the length of the input string s
. Set dp[0]
to 1
as there is one way to decode an empty string.i
, check if it is a *
. If so, multiply dp[i]
by 9
as there are 9 possible decodings for *
.1
, or 2
and the current character is between 0
and 6
, or if the previous character is *
, update dp[i]
accordingly.0
, ensure it forms a valid two-digit number with the previous character; otherwise, it cannot be decoded.dp[n]
modulo 10^9 + 7
as the final result.