Trie prefix search: Given a list of lowercase words and a lowercase prefix, return how many words start with that prefix. Duplicate words count separately.
Input: A JSON object { "words": string[], "prefix": string }.
Output: A JSON integer containing the matching word count.
Constraints:
- 0 <= words.length <= 100000
- Words and prefix contain lowercase a-z characters
- An empty prefix matches every word
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: MEDIUM. Variant: 8. Expect follow-up questions about complexity, edge cases, and alternative approaches.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked medium difficulty.
The signed-in workspace provides the tools required by the