class TrieNode{
vector<TrieNode*> v;
public:
TrieNode(){
v.resize(26,NULL);
}
};
void push(string word,TrieNode* root){
TrieNode* currRoot = root;
for(char letter:word){
if(currRoot->v[letter - 'a'] == NULL)
currRoot->v[letter - 'a'] = new TrieNode();
currRoot = currRoot->v[letter-'a'];
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter