void test2() { //Input: // addWord("ran"), addWord("rune"), addWord("runner"), addWord("runs"), addWord("add"), addWord("adds"), //addWord("adder"), addWord("addee"), search("r.n"), search("ru.n.e"), search("add"), search("add."), search("adde."), //search(".an."), search("...s"), search("....e."), search("......."), search("..n.r") // Output : // [false, false, true, true, true, false, true, true, false, false] //Expected : // [true, false, true, true, true, false, true, true, false, false] WordDictionary wd; wd.addWord("ran"); wd.addWord("rune"); wd.addWord("runner"); wd.addWord("runs"); wd.addWord("add"); wd.addWord("adds"); wd.addWord("adder"); wd.addWord("addee"); //assert(wd.search("r.n") == true); //assert(wd.search("ru.n.e") == false); //assert(wd.search("add") == true); //assert(wd.search("add.") == true); //assert(wd.search(".an.") == true); assert(wd.search("adde.") == true); assert(wd.search("...s") == true); assert(wd.search("....e.") == true); assert(wd.search(".......") == false); assert(wd.search("..n.r") == false); }
// Your WordDictionary object will be instantiated and called as such: // WordDictionary wordDictionary; // wordDictionary.addWord("word"); // wordDictionary.search("pattern"); int main(){ WordDictionary wordDictionary; wordDictionary.addWord("a"); wordDictionary.search("a"); cout<<wordDictionary.search("aa"); cout<< wordDictionary.search(".a"); }
int main() { WordDictionary dict = WordDictionary(); dict.addWord("apple"); std::cout << dict.search("apple") << std::endl; // returns true std::cout << dict.search("a..le") << std::endl; // returns false std::cout << dict.search("a...") << std::endl; // returns true return 0; }
int main() { WordDictionary wd; wd.addWord("a"); cout << wd.search("a.") <<endl;; cout << wd.search(".a") << endl;; wd.addWord("bad"); cout << wd.search("bad") <<endl;; cout << wd.search("b..") <<endl;; return 0; }
int main() { //Solution s; WordDictionary d; d.addWord("bad"); d.addWord("dad"); d.addWord("mad"); std::cout<<d.search("pad")<<std::endl; std::cout<<d.search("bad")<<std::endl; std::cout<<d.search(".ad")<<std::endl; std::cout<<d.search("b..")<<std::endl; }
int main() { bool rslt = false; WordDictionary* dict = new WordDictionary; dict->addWord("a"); dict->addWord("a"); rslt = dict->search("."); rslt = dict->search("a"); rslt = dict->search("aa"); rslt = dict->search("a"); rslt = dict->search(".a"); rslt = dict->search("a."); return 0; }
// Your WordDictionary object will be instantiated and called as such: int main() { WordDictionary wordDictionary; wordDictionary.addWord("word"); wordDictionary.addWord("wxrd"); wordDictionary.addWord("ssd"); wordDictionary.addWord("sd"); cout << boolalpha; cout << wordDictionary.search(".") << endl; cout << wordDictionary.search("woxxd") << endl; cout << wordDictionary.search("word") << endl; cout << wordDictionary.search("w.rd") << endl; cout << wordDictionary.search("wx.d") << endl; cout << wordDictionary.search("ss.") << endl; return 0; }
int main() { WordDictionary obj; obj.addWord("bad"); obj.addWord("dad"); obj.addWord("mad"); cout<<obj.search("pad")<<endl; cout<<obj.search("bad")<<endl; cout<<obj.search(".ad")<<endl; cout<<obj.search("b..")<<endl; cout<<endl; obj.addWord("at"); obj.addWord("and"); obj.addWord("an"); cout<<obj.search("a")<<endl; }
int main() { WordDictionary dict = WordDictionary(); dict.addWord("a"); cout << dict.search("a") << endl; cout << dict.search("b") << endl; return 0; }
// Your WordDictionary object will be instantiated and called as such: // WordDictionary wordDictionary; // wordDictionary.addWord("word"); // wordDictionary.search("pattern"); int main() { WordDictionary A; A.addWord("b"); A.addWord("bad"); A.addWord("dad"); A.addWord("mad"); cout<<A.search("pad")<<endl; cout<<A.search("bad")<<endl; cout<<A.search(".ad")<<endl; cout<<A.search("..d")<<endl; cout<<A.search("mad")<<endl; cout<<A.search("d")<<endl; // cout<<atoi("2147483648")<<endl; system("pause"); }
int main() { WordDictionary wordDictionary; wordDictionary.addWord("word"); cout << wordDictionary.search("pattern") << endl; return 0; }
int main () { WordDictionary wd; wd.addWord("bad"); wd.addWord("cad"); wd.addWord("adfad"); cout << wd.search(".") << endl; //cout << wd.search(".") << wd.search(".") << endl; }
void test_word_dict() { WordDictionary dict; string str1("bad"); string str2("dad"); string str3("mad"); dict.addWord(str1); dict.addWord(str2); dict.addWord(str3); cout << str1 << " insert in dict\n"; cout << str2 << " insert in ditc\n"; cout << str3 << " insert in dict\n"; str1 = "pad"; cout << str1 << " in dict? " << dict.search(str1) << endl; str1 = "bad"; cout << str1 << " in dict? " << dict.search(str1) << endl; str1 = ".ad"; cout << str1 << " in dict? " << dict.search(str1) << endl; str1 = "b.."; cout << str1 << " in dict? " << dict.search(str1) << endl; }
int main(int arg, char *argv[]) { // insert code here... cout << "LeetCode 211. Add and Search Word - Data structure design, C++ ...\n\n"; WordDictionary wordDictionary; wordDictionary.addWord("word"); wordDictionary.addWord("ward"); bool r = wordDictionary.search("word"); cout << (r ? "true" : "false") << '\n'; return 0; }
int main() { /* #ifndef ONLINE_JUDGE freopen ("in.txt" , "r" , stdin); freopen ("out.txt" , "w" , stdout); #endif */ WordDictionary wordDictionary; wordDictionary.addWord("word"); //cout<<"zhang"; cout<<wordDictionary.search("word"); return 0; }
int main() { WordDictionary wordDictionary; wordDictionary.addWord("at"); wordDictionary.addWord("and"); wordDictionary.addWord("an"); wordDictionary.addWord("add"); /* wordDictionary.search("a"); */ /* wordDictionary.search("a."); */ /* wordDictionary.search(".a"); */ /* cout << wordDictionary.search(".at")<<endl; */ wordDictionary.addWord("bat"); cout << wordDictionary.search(".at")<<endl; /* wordDictionary.search(".b"); */ /* wordDictionary.search("ab."); */ /* wordDictionary.search("."); */ /* wordDictionary.search(".."); */ return 0; }
//addWord("bad") //addWord("dad") //addWord("mad") //search("pad") -> false //search("bad") -> true //search(".ad") -> true //search("b..") -> true void test1() { WordDictionary wordDictionary; //wordDictionary.addWord("a"); //wordDictionary.addWord("as"); //wordDictionary.addWord("ass"); //wordDictionary.addWord("bad"); //wordDictionary.addWord("dad"); //wordDictionary.addWord("mad"); //assert(wordDictionary.search("a") == true); //assert(wordDictionary.search("as") == true); //assert(wordDictionary.search("ass") == true); //assert(wordDictionary.search("b") == true); //assert(wordDictionary.search("pad") == false); //assert(wordDictionary.search("bad") == true); //assert(wordDictionary.search(".ad") == true); //assert(wordDictionary.search("b..") == true); //addWord("at"), addWord("and"), addWord("an"), addWord("add"), search("a"), search(".at"), addWord("bat"), //search(".at"), search("an."), search("a.d."), search("b."), search("a.d"), search(".") //[false,false,true,true,false,false,true,false] wordDictionary.addWord("at"); wordDictionary.addWord("and"); wordDictionary.addWord("an"); wordDictionary.addWord("add"); assert(wordDictionary.search("a") == false); //printf("%d\n", wordDictionary.search(".at")); assert(wordDictionary.search(".at") == false); wordDictionary.addWord("bat"); assert(wordDictionary.search(".at") == true); assert(wordDictionary.search("an.") == true); assert(wordDictionary.search("a.d.") == false); assert(wordDictionary.search("b.") == false); assert(wordDictionary.search("a.d") == true); assert(wordDictionary.search(".") == false); }
void test3() { WordDictionary wd; wd.addWord("at"); wd.addWord("and"); wd.addWord("an"); wd.addWord("add"); assert(wd.search("a") == false); assert(wd.search("at") == true); wd.addWord("bat"); assert(wd.search("an.") == true); assert(wd.search("a.d.") == false); assert(wd.search("b.") == false); assert(wd.search("a.d") == true); //assert(wd.search(".") == false); }