GENERAL ELECTRIC (GE) | Off Campus OA 2022 | Design Add and Search Words Data Structure | Trie and DFS
Question · Posted Jun 2026
Problem Statement Design a data structure that supports adding new words and searching existing words. Implement the WordDictionary class: addWord(word) → Adds a word to the data structure. search(word) → Returns true if the word exists in the data structure. The search word may contain the wildcard character . which can represent any single lowercase English letter. Example Input addWord("bad") addWord("dad") addWord("mad") search("pad") search("bad") search(".ad") search("b..") Output false true true true Explanation "pad" → Not present "bad" → Present ".ad" ...
The full answer & interview discussion are available to premium members.
Log in Create a free account