diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/trie_prefix.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/trie_prefix.cpp')
-rw-r--r-- | other/trie_prefix.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/other/trie_prefix.cpp b/other/trie_prefix.cpp deleted file mode 100644 index b56e38b..0000000 --- a/other/trie_prefix.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// 208. Implement Trie (Prefix Tree) -#include "leetcode.h" - -class Trie { -public: - Trie() {} - void insert(string word) { - Trie *node = this; - for (char c : word) { - if (!node->next.count(c)) - node->next[c] = new Trie(); - node = node->next[c]; - } - node->is_word = true; - } - bool search(string word) { - Trie *node = this; - for (char c : word) { - if (!node->next.count(c)) - return false; - node = node->next[c]; - } - return node->is_word; - } - bool startsWith(string prefix) { - Trie *node = this; - for (char c : prefix) { - if (!node->next.count(c)) - return false; - node = node->next[c]; - } - return true; - } - -private: - map<char, Trie *> next = {}; - bool is_word = false; -}; - -int main() { - Trie *obj = new Trie(); - obj->insert("Trie"); - bool param_2 = obj->search("Trie"); - bool param_3 = obj->startsWith("Trie"); -} |