FastPrepTime-Aware Search Autocomplete
Problems/Time-Aware Search Autocomplete

Time-Aware Search Autocomplete

Roblox logoRoblox● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report gives all five inputs, an inclusive time cutoff, ranking by frequency then earliest time then alphabet, the top-k limit, and the full example where the ranking changes. We chose the alphabet, the limits, what happens with an empty prefix, and that the input is not changed. Our version is about 95% the same as the reported question.

You are given a search log. Log entry i says that the query searchQueries[i] was searched at integer time searchTimestamps[i]. You also get a list of prefix requests. Answer request j using only log entries whose timestamp is at most prefixTimestamps[j].

A query matches request j when it starts with prefixes[j]. A query that is exactly equal to the prefix also matches. Rank the different matching queries, listing each query once, like this:

  1. Queries with more log entries at or before the request time come first.
  2. If counts are equal, the query whose first search at or before the request time is earlier comes first.
  3. Any ties left are broken by alphabetical order.

For each request, return at most resultCount query strings in that ranked order. Give the answers in the same order as the requests appear in the input. A request gets an empty list when no query matches or when resultCount is zero.

The two search arrays have the same length, and so do the two request arrays. Every log entry counts, even when the same word appears more than once at the same time. Either timestamp array may be out of order, and several entries may share a time. Search words are nonempty and use lowercase English letters. Prefixes use the same letters and may be empty. An empty prefix matches every word. Do not change any input array, and compare the words exactly as they are given. The search log and the request list may each be empty.

Use only searches recorded at or before each request’s time. Later searches can change the counts, so a later request with the same prefix may get a different ranking.

Function

autocompleteAsOf(searchQueries: String[], searchTimestamps: int[], prefixes: String[], prefixTimestamps: int[], resultCount: int) → List<List<String>>

Examples

Example 1

searchQueries = ["apple","app","apple","apply","banana","app","app"]searchTimestamps = [1,2,3,4,5,6,7]prefixes = ["app","app","app","b","c"]prefixTimestamps = [3,6,7,5,10]resultCount = 2return = [["apple","app"],["apple","app"],["app","apple"],["banana"],[]]

At time 3, apple has two searches and app has one, so apple comes first. At time 6 both have two searches, and apple wins because its first search came earlier. At time 7 app has three searches and moves to first place. The last two requests return banana and an empty list, since no word starts with c.

Example 2

searchQueries = ["app","apple","app","apple"]searchTimestamps = [9,1,1,3]prefixes = ["app","app","app","app"]prefixTimestamps = [9,0,3,1]resultCount = 1return = [["app"],[],["apple"],["app"]]

The answers follow the order of the requests in the input, not the order of their times. At time 9 both words have count 2 and earliest time 1, so app comes first in alphabetical order. Nothing has been searched by time 0, so that list is empty. At time 3 apple has more searches, so it wins. At time 1 the counts and earliest times are tied again, so app wins.

Example 3

searchQueries = ["zebra","apple","zebra","apple","alpha","alpha"]searchTimestamps = [1,2,3,4,2,4]prefixes = ["","a","z","x"]prefixTimestamps = [4,4,4,4]resultCount = 2return = [["zebra","alpha"],["alpha","apple"],["zebra"],[]]

All three words have count 2. Zebra ranks first because its earliest search is at time 1. Alpha and apple both first appear at time 2, so alpha comes before apple in alphabetical order. The empty prefix matches every word. Each other prefix first keeps only the words that start with it, then ranks them.

Constraints

  • 0 <= searchQueries.length = searchTimestamps.length <= 1000.
  • 0 <= prefixes.length = prefixTimestamps.length <= 50.
  • Every search word has length between1 and30; every prefix has length between0 and30. All characters are lowercase English letters.
  • 0 <= searchTimestamps[i], prefixTimestamps[j] <= 1000000000.
  • 0 <= resultCount <= 20.
  • The paired arrays (queries with their times, prefixes with their times) have equal lengths. Your function must leave every input unchanged.

More Roblox Phone Screen questions

  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026
  • Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026

Similar questions at other companies

  • Stable Top K Frequent WordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Top N Frequent Words in a FileMeta · PHONE SCREENMeta interview questions
  • Sort Characters by How Often They AppearAdobe · PHONE SCREENAdobe interview questions
  • Top K Keys from JSON RecordsCapital One · ONSITE INTERVIEWCapital One interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN
  • Group AnagramsWorkday · PHONE SCREEN
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions
  • Bank Account Balances (Part 2): Monthly ReconciliationStripe · PHONE SCREENStripe interview questions

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public List<List<String>> autocompleteAsOf(String[] searchQueries, int[] searchTimestamps, String[] prefixes, int[] prefixTimestamps, int resultCount) {
      // Return one ranked suggestion list per request.
    }

}
Checking account…