Longest prefix matching – A Trie based solution in Java Given a dictionary of words and an input string, find the longest prefix of the string which is also a word in dictionary. Examples: Let the dictionary contains the following words: {are, area, base, cat, cater, children, basement} Below are some input/output examples: -------------------------------------- Input String Output -------------------------------------- caterer cater basemexy base child < Empty > Solution We build a Trie of all dictionary words. Once the Trie is built,
Read full article from Longest prefix matching - A Trie based solution in Java | GeeksforGeeks