Search⌘ K

DIY: Design Add and Search Words Data Structure

Explore how to design and implement a WordDictionary data structure in Go that supports adding new words, searching with wildcard support, and retrieving all stored words. Understand the construction of member functions for adding words, conducting searches with dots representing any letter, and listing all stored words. This lesson helps you build problem-solving skills relevant to coding interviews focused on data structure design.

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 class. Here is how it should be implemented:

  • NewWordDictionary(): This function will initialize the object.
  • AddWord(word): This function will add word
...