Given a set of Strings $S$ with a constant-size alphabet, find all the strings in $S$ that form the string $Q$ after deleting some of their characters.
If you are familiar with SQL it can also be asked as: what is the best algorithm to implement SQL like query with multiple % signs?
For example, below is a list of strings that much fly
- Buterfly
- falseWay
- flyfly
- officePlay
And here are some that don't
- Fly
- fl
- yfl
What is the best algorithm for solving this problem?
* You can assume that $S$ is sorted or structured in any other way.
One simple approach is to scan the string from the start looking for "f". If you find that, start from there looking for "l". If you find that, look for "y"