Solved LeetCode program · 453 of 1,000
#0639 · Decode Ways II
Original English source
The source is "1*". The size is the number of characters in source. The table is a list of size plus 1 zeros. Set item 0 of table to 1.
For every position from 1 to size.
The current is character (position minus 1) of source. The previous is current. If position is more than 1, set previous to character (position minus 2) of source. If current is "*", set item position of table to (item position of table plus 9 times item (position minus 1) of table) modulo 1000000007. If current is between "1" and "9", set item position of table to (item position of table plus item (position minus 1) of table) modulo 1000000007. The pairways is 0. If position is more than 1 and previous is "*" and current is "*", set pairways to 15. If position is more than 1 and previous is "*" and current is between "0" and "6", set pairways to 2. If position is more than 1 and previous is "*" and current is between "7" and "9", set pairways to 1. If position is more than 1 and previous is "1" and current is "*", set pairways to 9. If position is more than 1 and previous is "2" and current is "*", set pairways to 6. If position is more than 1 and previous is "1" and current is between "0" and "9", set pairways to 1. If position is more than 1 and previous is "2" and current is between "0" and "6", set pairways to 1. If pairways is more than 0, set item position of table to (item position of table plus pairways times item (position minus 2) of table) modulo 1000000007.
Show item size of table.
Expected stdout
18