"Top k hotels" coding problem: same as the well-known version, but the input contains punctuation marks that must be handled.
Asked in the online assessment (HackerRank) stage. The assessment also included a 9-question multiple-choice quiz on ML topics.
Implement top_k_hotels(positive_keywords, negative_keywords, hotel_ids, reviews, k). Each positive keyword occurrence adds 3 points, and each negative keyword occurrence subtracts 1 point. Matching is case-insensitive, and punctuation separates words. Return the top k distinct hotel IDs ordered by descending score, then ascending hotel ID.
def top_k_hotels(positive_keywords, negative_keywords, hotel_ids, reviews, k):