Booking.com Coding Interview: Review Sentiment Score
Based on questions reported for Booking.com interviews
The interviewer opens
Welcome, and thanks for joining this interview for the software engineer role at Booking.com. We'll work through one coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause the interview anytime with the Pause button at the top right.
The problem is about scoring guest reviews by counting sentiment words, which is the kind of text signal a travel platform cares about. It's up in the Problem tab, so please read it through and ask me any questions before you start.
The problem
Booking.com scores guest reviews by counting sentiment words.
review: the review text, possibly with mixed case, punctuation and digits.positive_words: lowercase positive words.negative_words: lowercase negative words (disjoint frompositive_words).
A word is a maximal run of letters (a-z, A-Z); everything else separates words. Matching is case-insensitive and on whole words only ("clean" does not match "uncleanly"). Each occurrence of a positive word adds 3 points, each occurrence of a negative word subtracts 1. Return the review's total score.
Example: review = "Great location, but the room was NOISY and dirty. Great staff!", positive_words = ["great", "clean"], negative_words = ["dirty", "noisy"] → 4
Sizes: review length up to 10^5; each word list up to 10^4 words.