Complete the code to insert a character into the Trie node's children.
node->children[[1]] = new TrieNode();We use the current character of the word (word[i]) as the key to insert into the children map.
Complete the code to check if a prefix exists in the Trie.
if (node->children.find([1]) == node->children.end()) return false;
We check if the current character of the prefix exists in the children map.
Fix the error in the code to mark the end of a word in the Trie.
node->[1] = true;The boolean flag 'isWord' marks the end of a valid word in the Trie.
Fill both blanks to complete the Trie search function for a word.
for (int i = 0; i < word.size(); i++) { if (node->children.find([1]) == node->children.end()) return false; node = node->children[[2]]; }
Both blanks require the current character of the word to traverse the Trie correctly.
Fill all three blanks to complete the code that builds an unordered_map of words longer than 3 characters to their lengths.
std::unordered_map<std::string, int> lengths; for (const auto& [3] : words) { if ([2] > 3) { lengths[[1]] = [2]; } }
We map each word to its length if the length is greater than 3. 'word' is the loop variable.