7 questions. Covers Wildcard search with dots.
Questions 1 to 5 of 7
bad
dad
mad
WordDictionary
cpp WordDictionary words; for (std::string_view w : {"moon", "mood", "book"}) words.addWord(w); std::cout << std::boolalpha << words.search("moo") << '\n';
cpp WordDictionary fox; for (std::string_view w : {"fox", "fig", "fan"}) fox.addWord(w); std::cout << std::boolalpha << fox.search("f.g") << '\n';
cpp static bool searchFrom(const Node* node, std::string_view pattern, std::size_t pos) { if (pos == pattern.size()) return node->isEnd; if (pattern[pos] == '.') { for (const auto& child : node->children) { if (child) return searchFrom(child.get(), pattern, pos + 1); } return false; } // plain-letter case omitted }
5 question(s) left on this page.