Question
Build an autocomplete index from a list of (word, frequency) pairs. Then for each query prefix, return up to 3 completions that start with that prefix, ranked by frequency descending; break ties by lexicographic order of the word ascending. Process the queries in order and return a list of result lists (each a list of words). A query with no matching word yields an empty list.
autocomplete(words: list[list], queries: list[str]) → list[list[str]][[["cat",5],["car",9],["card",2],["dog",7]],["ca","do","x"]]out[["car","cat","card"],["dog"],[]]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.