Snippets Collections
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'];
    }
}
star

Fri Nov 18 2022 17:37:59 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/word-break/

#c++ #trienode

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension