Code Room
CodingEasycod-g554
Subject TrieLevel Entry–Mid~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a list of words (possibly with duplicates) and a list of query strings, return for each query the number of words that have the query as a prefix. Build a trie where each node stores a counter of how many inserted words pass through it; then each query walks down the trie and reads the counter at its terminal node (0 if the path breaks). Return the list of prefix counts in query order.

Implement
prefix_count(words: list[str], queries: list[str]) → list[int]
Examples
in[["apple","app","apricot","banana"],["ap","app","b","xyz","apple"]]out[3,2,1,0,1]
What a strong answer looks like

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.

Run or narrate your approach, then ask the coach.