Yelp interview question

Leet code style n-gram type problem.