← 返回 apple 的题目列表Optimized Search in Trie
类型:online_judge
apple
Implement a Trie structure that supports the following operations:
Insert a string.
Search for a string and return if it's in the Trie. Provide a function optimize_search that, given a prefix, returns all strings in the Trie matching that prefix. Optimize for search efficiency. Assume the Trie contains at most 1000 strings, each with a maximum length of 100 characters.
Test Cases
Example input for the function:
optimize_search('app')
Expected Output: ['apple', 'appetizer', 'application']
You can assume apple, appetizer, and application are already inserted in the Trie.
Example
Input
app