The Cytes Lottery is the biggest lottery in the world. On each ticket, there is a string of a-z letters. The company produces a draw string S. A person win if his/her ticket string is a special substring of the draw string. A special substring is a substring which can be formed by ignoring at most K characters from drawString.
For example, if draw string = “xyzabc” and tickets are [ac zb yhja] with k=1 then the winning tickets will be 2
i.e ac(won by ignoring “b” in drawstring) and zb (won by ignoring “a” in drawstring).
Now, some people change their ticket string in order to win the lottery. To avoid any kind of suspicion, they can make the following changes in their string.
they can change character ‘o’ to character ‘a’ and vice versa.
They can change character ‘t’ to character ‘I’ and vice versa.
They can erase a character from anywhere in the string.
Note that they can ignore at most ‘K’ character from the string to get a match with the ticket string. Write an algorithm to find the number of people who win the lottery (either honestly or by cheating).
Eg. draw string = aabacd, K=2
tickets = [abcde acmfgtld]
abcde -> abcd (erase a character)
abcd matches with the substring "abacd" of the draw string (after ignoring one character)
Hence, abcd will win the lottery.
How to approach this question?