Hotel Review Sentiment Ranking

Hotel Review Sentiment Ranking

You are given a string positive_keywords containing space-separated words, and two arrays: hotel_ids and reviews. The arrays represent reviews for various hotels where reviews[i] corresponds to hotel_ids[i]. Your task is to rank the hotels based on the number of times any of the positive_keywords appear in their reviews. Requirements: A keyword match is case-insensitive. If a hotel has multiple reviews, the total count of keyword matches across all its reviews should be summed. Return the list of unique hotel IDs sorted in descending order by their total match count. If two hotels have the same match count, sort them by their hotel_id in ascending order. Example: Input: keywords = 'smart clean breakfast' hotel_ids = [1, 2, 1] reviews = ['This hotel is clean', 'The breakfast is good', 'The rooms are smart and clean'] Output: [1, 2] Explanation: Hotel 1 has 3 matches ('clean', 'smart', 'clean'). Hotel 2 has 1 match ('breakfast').
JavaHashingSortingHashSetHashMap
00
Read
1
InterviewGPT

AI-powered tools to help you succeed in tech interviews — from resume to offer.

Products

  • Interview Solver
  • Question Bank
  • Golden Blogs
  • Intervipedia
  • Application Tools

Company

  • Pricing
  • FAQ
  • About

Legal

  • Privacy Policy
  • Terms of Service

© 2026 InterviewGPT Inc. All rights reserved.

All systems operationalUS-East

Made with ♥ for developers