Design Add and Search Words Data Structure
Explore how to design a WordDictionary data structure that lets you add words and search using exact matches or wildcard dots. Understand how to handle multiple searches efficiently within C# by implementing and using trie data structures. This lesson helps you master dynamic string operations vital for coding interviews.
We'll cover the following...
Statement
Design a data structure called WordDictionary that supports the following functionalities:
-
Constructor: This function will initialize the object.
-
Add Word(word): This function will store the provided word in the data structure.
-
Search Word(word): This function will return TRUE if any string in the WordDictionary object matches the query word. Otherwise, it will return FALSE. If the query word contains dots,
., each dot is free to match any letter of the alphabet.For example, the dot in the string “.ad” can have ...