← 返回 amazon 的题目列表Implement Spell Check and Tab Completion
类型:online_judge
Implement a simple spell check and tab completion functionality. First, construct a Trie data structure to store words from a dictionary. Then provide the following functionalities: 1. When given an input word, check if the word exists in the dictionary. If not, find all possible words within a one-letter difference and suggest them. 2. When given a word prefix, return all dictionary words starting with that prefix. The dictionary size is 10^5. Please implement these functionalities in code and provide three test cases to validate your solution.
Example
Input
apple
er
1
ap