Yelp Interview Question

It is just an algorithm question.