Decode ways with wildcards
A message of digits is encoded to letters via 'A'->1 ... 'Z'->26. The encoded string may contain '*', which stands for any digit 1-9. Return the number of ways to decode the string, modulo 1000000007. A '0' alone is invalid; valid two-digit groups are 10-26. 1 <= len(s) <= 100000, characters are digits or '*'. Example: '1*' -> 18 (1 then 1-9 = 9 ways, plus 11-19 = 9 ways).
Implement
num_decodings_ii(s: str) → intExamples
in
["1*"]out18What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 32 min
solution.py
InputExpectedGot
["1*"]18not run yetsample