DIY: Design Add and Search Words Data Structure
Explore how to design a WordDictionary data structure that supports adding new words, searching with exact or wildcard matches, and retrieving all stored words. This lesson helps you implement core data structure methods to efficiently manage string queries, enhancing your problem-solving skills for coding interviews.
We'll cover the following...
We'll cover the following...
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:
__init__(): This function will initialize the object.add_word(word): This function will addword