Code RoomDecode ways with wildcards
HardPrep Room Coding #1182

Decode ways with wildcards

CodingAlgorithms & data structuresMid–Senior~32 min

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) → int
Examples
in["1*"]out18
What 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
InputExpectedGot
["1*"]18not run yetsample