Yelp interview question

Asked one algorithm question and solve it with backtracking.