Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Most Frequent Review Across Locations

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Most Frequent Review Across Locations. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Meta Quest collects review strings grouped by bookstore or retail location. Given a dictionary mapping each location to its list of reviews, return the review that appears at the most distinct locations after removing duplicate reviews within each location.

A review contributes at most once per location. If multiple reviews have the same highest frequency, return the lexicographically smallest review. If the input dictionary is empty or contains no reviews, return an empty string.

Formal Specification

Implement most_frequent_review(reviews_by_location), where reviews_by_location is a dictionary with string keys and list-of-string values. Return one string according to the rules above.

Constraints

  • 0 <= number of locations <= 10^5
  • The total number of review entries across all locations is at most 10^6
  • Each review is a non-empty string of length at most 200
  • Duplicate reviews within one location count only once
  • Comparisons are case-sensitive
  • Return an empty string when no review exists

Function Signature

def most_frequent_review(reviews_by_location):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output