Return dictionary words matching a prefix
GoogleSoftware Engineer · Technical ScreenLast updated
This problem evaluates string-processing and filtering skills, focusing on exact prefix matching, case sensitivity, duplicate handling, and edge-case management over arrays of strings. Commonly asked in Coding & Algorithms interviews, it assesses practical implementation ability and understanding of algorithmic complexity at an implementation-level (basic to intermediate).
You are given a list of strings words (a dictionary) and a string prefix.
Return all words in words that start with prefix.
Clarifications/constraints:
- Matching is case-sensitive.
- If no words match, return an empty list.
- If
wordscontains duplicates, include duplicates in the output. - You may return the result in any order unless the interviewer asks for a specific ordering (e.g., lexicographic).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.