Implement Store Autocomplete
Company: Uber
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates string matching, prefix search, and data structure selection skills by requiring an autocomplete method that returns entries beginning with a given prefix from a list of store names.
Constraints
- 0 <= len(stores) <= 100000
- 0 <= len(s) <= 100
- 0 <= len(store_name) <= 100 for each store name
- Matching is case-sensitive
- The output must preserve the original relative order of matching stores
Examples
Input: (["McDonald's", "KFC", "Burger king", "Bites", "Biscuit shop"], "B")
Expected Output: ["Burger king", "Bites", "Biscuit shop"]
Explanation: Only the store names starting with uppercase 'B' match, and they are returned in their original order.
Input: (["McDonald's", "KFC", "Burger king", "Bites", "Biscuit shop"], "Bi")
Expected Output: ["Bites", "Biscuit shop"]
Explanation: Both 'Bites' and 'Biscuit shop' start with 'Bi', while 'Burger king' starts with 'Bu'.
Input: (["Burger king", "bistro", "Bites"], "b")
Expected Output: ["bistro"]
Explanation: Matching is case-sensitive, so lowercase 'b' only matches 'bistro'.