Quick Overview

Practice a Google coding interview problem focused on return words matching a typed prefix. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Return Words Matching a Typed Prefix

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given words and a query prefix, return all words starting with that prefix in lexicographic order. Implement: ```python def prefix_matches(words: list[str], prefix: str) -> list[str]: pass ```

Overview: Practice a Google coding interview problem focused on return words matching a typed prefix. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Read the full Google Software Engineer interview experience this question came from

Return all words that start with a given prefix.

Examples

Input: {"words":["car","cat","dog"],"prefix":"ca"}

Expected Output: ["car","cat"]

Explanation: Two matches.

Input: {"words":[],"prefix":"a"}

Expected Output: []

Explanation: Empty.

Loading coding console...