DIY: Design Add and Search Words Data Structure
Explore how to design and implement a WordDictionary data structure that supports adding new words, searching with wildcards, and retrieving all stored words. Learn to develop these core functions in Swift to solve common coding interview problems involving string manipulation and data organization.
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:
WordDictionary(): This function will initialize the object.void addWord(word): This