Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 562 Bytes

README.md

File metadata and controls

21 lines (14 loc) · 562 Bytes

Implement an autocomplete system

This problem was asked by Twitter.

Description

Implement an autocomplete system. That is, given a query string s and a set of all possible query strings, return all strings in the set that have s as a prefix.

For example, given the query string de and the set of strings [dog, deer, deal], return [deer, deal].

Hint: Try preprocessing the dictionary into a more efficient data structure to speed up queries.

Examples

Input:  
  prefix: "de"
  dictionary: ["dog", "deer", "deal"]
  Output: ["deer", "deal"]