7
next.resize(26, NULL); // one pointer for each character17
void insert(string word) {21
// if pointer to char doesn't exist create one22
if (cur->next[c - 'a'] == NULL) {23
cur->next[c - 'a'] = new tr();25
cur = cur->next[c - 'a'];28
// set as end or valid word32
bool search(string word) {36
// if pointer to char doesn't exist then word is not present37
if (cur->next[c - 'a'] == NULL) {41
cur = cur->next[c - 'a'];44
// check if it is prefix or a word52
// here we don't check if it is end or not53
bool startsWith(string prefix) {56
for (auto c : prefix) {57
if (cur->next[c - 'a'] == NULL) {61
cur = cur->next[c - 'a'];69
* Your Trie object will be instantiated and called as such:70
* Trie* obj = new Trie();72
* bool param_2 = obj->search(word);73
* bool param_3 = obj->startsWith(prefix);