Tag: trie

  • Word Search II

    Given a m*n board of letters and a list of words , find those words present in the board. For example, Given the board: and the below list of words: [“oath”,”pea”,”eat”,”rain”] The output is “eat” ,”oauth” Try out the solution here: https://leetcode.com/problems/word-search-ii/solution/ Solution: Let’s use Trie data structure to solve this problem. We could use…

  • A Word dictionary for adding and searching words

    Create a word dictionary to add and search words. You can also search using ‘.’ regular expression, That is searching for the word “.at” will return true if the dictionary contains words like cat , mat etc since the first letter can be anything. Try out the solution here: https://leetcode.com/problems/design-add-and-search-words-data-structure/ Solution: The solution to this…

  • How to implement Trie Data Structure?

    Trie is a datastructure useful to store set of words. It is a tree with a lot of children , one for each letter of the alphabets. So if you want to store lower case English letter words each node can have unto 26 child nodes. Every word is represented by as many nodes as…