Solved LeetCode program · 44 of 1,000
#0044 · Wildcard Matching
Original English source
The text is "adceb". The pattern is "*a*b". The textsize is the number of characters in text. The patternsize is the number of characters in pattern. The width is patternsize plus 1. The height is textsize plus 1. The size is width times height. The table is a list of size zeros. Set item 0 of table to 1.
For every column from 1 to patternsize.
If character (column minus 1) of pattern is 42 and item (column minus 1) of table is 1, set item column of table to 1.
For every row from 1 to textsize.
For every column from 1 to patternsize.
The index is row times width plus column. The symbol is character (column minus 1) of pattern. If symbol is 42 and item (index minus width) of table is 1, set item index of table to 1. If symbol is 42 and item (index minus 1) of table is 1, set item index of table to 1. If symbol is 63 and item (index minus width minus 1) of table is 1, set item index of table to 1. If symbol is character (row minus 1) of text and item (index minus width minus 1) of table is 1, set item index of table to 1.
The last is one less than size. If item last of table is 1, report true. Otherwise, report false.
Expected stdout
true