Trie implementation

question–>
https://practice.geeksforgeeks.org/problems/trie-insert-and-search0651/1#
code–>

void insert(struct TrieNode *root, string key) {
    // code here
    struct TrieNode* temp=root;
    for(int i=0;key[i]!='\0';i++){
        char ch=key[i];
        if(temp->children[ch-'a']==NULL){
            struct TrieNode* child=getNode();
            temp->children[ch-'a']=child;
        }
        else{
            temp=temp->children[ch-'a'];
            
        }
    }
    temp->isLeaf=true;
}

// root : root node of the trie
// key : string to search in the trie
// Returns true if key presents in trie, else false

bool search(struct TrieNode *root, string key) {
    // code here
    struct TrieNode* temp=root;
    for(int i=0;key[i]!='\0';i++){
        char ch=key[i];
        if(temp->children[ch-'a']!=NULL){
             temp=temp->children[ch-'a'];
        }
        else{
            return false;
        }
    }
    return temp->isLeaf;
}

Not passing all testcases help!!

@asaurabh_26 are you there?

here you have missed one line
temp=temp->children[ch-‘a’];
after this all testcase will passed

yes it passed all testcases

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.