208. Implement Trie (Prefix Tree)

# Medium

Key idea:

Every TrieNode stores one letter, there are alph_size of children in each layer. Root doesn't store any letter, the last leaf stores isEndOfWord other than letter.

class TrieNode {
public:
    TrieNode *child[26];
    bool isWord;
};
"T" means isEndOfWord = True. Refer to https://www.geeksforgeeks.org/trie-insert-and-search/

for(auto &a : s) 的用法注意了,是只能用指针么?

Last updated

Was this helpful?