aboutsummaryrefslogtreecommitdiff
path: root/other/add_search_words_data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/add_search_words_data.cpp')
-rw-r--r--other/add_search_words_data.cpp35
1 files changed, 0 insertions, 35 deletions
diff --git a/other/add_search_words_data.cpp b/other/add_search_words_data.cpp
deleted file mode 100644
index 5c5e0f4..0000000
--- a/other/add_search_words_data.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "leetcode.h"
-
-class WordDictionary {
-public:
- WordDictionary() {}
- void addWord(string word) { words[word.size()].push_back(word); }
- bool search(string word) {
- for (auto s : words[word.size()])
- if (isEqual(s, word))
- return true;
- return false;
- }
-
-private:
- unordered_map<int, vector<string>> words;
- bool isEqual(string a, string b) {
- for (int i = 0; i < a.size(); i++) {
- if (b[i] == '.')
- continue;
- if (a[i] != b[i])
- return false;
- }
- return true;
- }
-};
-
-int main() {
- WordDictionary *obj = new WordDictionary();
- obj->addWord("WordDictionary");
- bool param_2 = obj->search("WordDictionary");
- if (param_2)
- cout << "found";
- else
- cout << "not found";
-}