← 返回 pinterest 的题目列表Search Engine Input Suggestions
类型:online_judge
Design an input suggestion system for a search engine. As a user types, the system should display possible query suggestions in real time. Assume we have a predefined set of queries, and based on a given input string, return suggestions in real time.
Input
A list of query strings, and the current prefix being typed by the user.
Output
A list of suggestion strings that match the prefix, sorted in alphabetical order.
Example
Input: queries = ['apple', 'app', 'application', 'apply', 'banana'], prefix = 'app'
Output: ['app', 'apple', 'application', 'apply']
Input: queries = ['dog', 'deer', 'deal', 'dodge'], prefix = 'de'
Output: ['deal', 'deer']
Constraints
There are up to 1000 query strings.
Each query can be up to 50 characters long.
The user-input prefix can be up to 20 characters long.
Example
Input
queries = ['apple', 'app', 'application', 'apply', 'banana']
prefix = 'app'