Back to problems

Highlight Phrases in Review

Algorithm · Airbnb · Medium

You are building a feature for a travel-review platform that annotates key concepts inside a user’s written review. You receive a review string and a list of mapping pairs. Each pair associates a phrase with a category name. Your job is to process the review and enclose every occurrence of any mapped phrase in the format "[category]{exact found text}", using the category that corresponds to the matched phrase. Apply these rules when performing the replacements: Whole‑token…

Checking your access…