Skip to the code
+50 XP

#502 Icon Codes With Blanks

hard

Icons are numbered 1 to 26, and a list of icons is stored by writing their numbers one after another, so (1, 12) becomes "112". Some digits of an old code were smudged and are now written as *. Each * stands for one digit from 1 to 9 (never 0).

Write countBlankReadings(code) that returns how many icon lists could have produced code, counting every way to fill in the * digits and every way to split the result into numbers from 1 to 26 without leading zeros.

Return the count modulo 1000000007.

Example 1

Input: code = "*2"
Output: 11

9 readings as two icons (any digit, then 2), plus 12 and 22 as single icons.

Example 2

Input: code = "*7"
Output: 10

9 readings as two icons, plus 17 as one icon (27 is too big).

Constraints

  • 1 <= code.length <= 300000
  • code contains digits and *.
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).