Back to problems

Design Search Autocomplete System

Object-Oriented Programming · Roblox · Medium

You receive three arrays: queries[i] represents a search phrase submitted by a user. timestamps[i] gives the submission time for queries[i]. prefixes[j] represents text entered into an autocomplete field. For every prefix, produce all unique queries that begin with it. Rank those queries using these criteria, in order: Queries seen more often come first. When frequencies are equal, the query with the earlier first timestamp comes first. If those values are also equal, order…

Checking your access…