Search⌘ K
AI Features

DIY: Design Add and Search Words Data Structure

Explore how to implement a WordDictionary data structure in Elixir that supports adding words, searching with exact or wildcard queries, and retrieving all stored words. This lesson helps you understand core concepts for managing dynamic word collections and solving related coding interview problems effectively.

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
...