Use to check is a string is a substring of another string
The hardest part is creating the bad matching table.
Create like this
T O O T H
0 1 2 3 4
length = 5
T O H *
T = 5-3-1 = 1
O = 5-2-1 = 2
H = length = 5
* = 5
Start comparing from the right.
If there is a mismatch, check what the letter is in the upper longer string.
If it is a letter in the bad matching table, move our bottom smaller string forward that many positions.
Otherwise, * which moves the length of the string.
For example:
TRUSTHARDTOOTHBRUSHES
the first case we get is H is not T.
So the letter we hit is H.
H IS is in bad matching table.
But is equal to length and thereforce we move 5 positions.
However, had we hit a O we would have moved two.
TRUSO would have made us move 2