Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 1.44 KB

Notes.md

File metadata and controls

32 lines (21 loc) · 1.44 KB

implement a trie

Longest Word in Dictionary

  • When we have a dictionary, we can use a trie to find the longest word in the dictionary.
  • When We can Built a word by adding one letter at a time?
    • every letter in the word is a word.

Map Sum Pairs

  • check if the word already exists int the Trie, if so, update it with the new value. if not insert it.
  • keep track of the word/prefix value in the Trie.
  • if it is a prefix, we can just update the value of the prefix.

replaceWords

Design Add and Search Words

  • add word to the trie.
  • search word in the trie, if the word is match return true, if not return false.
  • the dot is macth any charcter. if the word is starting with a dot, continue search all nodes that end with the same charcter.
  • if the word is not starting with a dot, continue search all nodes that start with the same charcter pf the word and end with any char.