Apple interview question

Design the algorithm of grep