Google interview question

Count matching words using the most efficient algorithm