...

/

DIY: Design Add and Search Words Data Structure

DIY: Design Add and Search Words Data Structure

Solve the interview question "Design Add and Search Words Data Structure" in this lesson.

Problem statement

Design a data structure that supports the following functions:

  • Adding new words.
  • Finding if a string matches any previously added string.
  • Returning all the words that are present in the data structure.

Let’s call this data structure the WordDictionary module. Here is how it should be implemented:

  • init: This function will initialize the object.
  • add_word(obj, word): This function
...