Use trie tree to compute the edit distance