PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

Practice a Google coding interview problem focused on build prefix lookup with a trie. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Build Prefix Lookup with a Trie

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Build prefix lookup for repeated queries. Given words and query prefixes, return matching words for each query in lexicographic order. Implement: ```python def prefix_lookup(words: list[str], queries: list[str]) -> list[list[str]]: pass ```

Quick Answer: Practice a Google coding interview problem focused on build prefix lookup with a trie. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Return lexicographic word matches for each prefix query.

Examples

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

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

Explanation: Two queries.

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

Expected Output: [[]]

Explanation: No words.

Input: {"words":["a","aa"],"queries":[""]}

Expected Output: [["a","aa"]]

Explanation: Empty prefix.

Input: {"words":["b","a"],"queries":["a","b"]}

Expected Output: [["a"],["b"]]

Explanation: Sorted.

Input: {"words":["same","same"],"queries":["sa"]}

Expected Output: [["same","same"]]

Explanation: Duplicates.

Input: {"words":["abc"],"queries":["x"]}

Expected Output: [[]]

Explanation: No match.

Input: {"words":["apple","app","ape"],"queries":["ap","app"]}

Expected Output: [["ape","app","apple"],["app","apple"]]

Explanation: Multiple prefixes.

Input: {"words":["A","a"],"queries":["a"]}

Expected Output: [["a"]]

Explanation: Case sensitive.

Last updated: Jul 4, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Common Free Time Slots Across Calendars - Google (easy)
  • Deterministic Task Execution Order - Google (easy)
  • Busiest Rental Car - Google (easy)
  • Count Clusters of 2D Points Within a Radius - Google (medium)
  • Infection Spread on a Grid (Cellular Automaton) - Google (hard)