C++ || Trie || Easy
Here i think of simple forming a trie and inserting all the predefined entity in trie and at the end of this insert equivalent symbol that we want to replace\n\
Here i think of simple forming a trie and inserting all the predefined entity in trie and at the end of this insert equivalent symbol that we want to replace\n\nonce we have inserted into trie we will start traversing the given text and we search for matching whenever we caught any \'&\' \n\nCode is simple and can be understood please go through it\n\n```\nclass MyTrie\n{\n    private :\n    vector<MyTrie*> children;\n    char symbol; // to store the symbol which we have to replace e.g &amp -> \'&\'\n    \n    public :\n    MyTrie()\n    {\n       children=vector<MyTrie*>(26,NULL);\n       symbol=\'#\';//By default symbol we will be \'#\' but at the point where an entity is ending we will replce it with equivalent symbol\n    }\n    \n    void insert(string word,char sym)\n    {\n        MyTrie *root=this;\n        int n=word.length();\n        for(int i=0;i<n;i++)\n        {\n            if(root->children[word[i]-\'a\']==NULL)\n            {\n                root->children[word[i]-\'a\']=new MyTrie();\n            }\n            \n            root=root->children[word[i]-\'a\'];\n        }\n        root->symbol=sym;//Here we are storing the equivalent symbul as it is end of valid entity\n        return ;\n    }\n    \n    pair<char,int> serach(string &text,int k)\n    {\n        MyTrie *root=this;\n        int n=text.size();\n        int i=k;\n        for(i=k;i<n;i++)\n        {\n            if(text[i]>=\'a\' && text[i]<=\'z\')//as it has been given in question there can be any Ascii value so we are checking whether it lies within alphabet or not\n\t\t\t//we have entered into this bloc because the text[i] is alphabet\n            {\n                \n               if(root->children[text[i]-\'a\']==NULL)\n               {\n                   \n                   return {\'0\',i};//if dont matches return \'0\' symbol which we will use as flag to check whether match was ssuccessful or not in our main program\n               }\n            }\n            else\n            {\n                return {\'0\',i};\n            }\n            root=root->children[text[i]-\'a\'];\n            if(root->symbol!=\'#\')//We are checking whether we have hit any vallid entity or not \n            {\n                break;\n            }\n        }\n        \n        return {root->symbol,i+1};\n    }\n};\nclass Solution {\npublic:\n    string entityParser(string text) \n    {\n        MyTrie *root=new MyTrie();\n        root->insert("quot",\'"\');\n        root->insert("apos",39);\n        root->insert("amp",\'&\');\n        root->insert("gt",\'>\');\n        root->insert("lt",\'<\');\n        root->insert("frasl",\'/\');            \n    \n    int n=text.length(),i=0;\n    string res;\n    \n    while(i<n)\n    {\n        if(text[i]==\'&\')\n        {\n           auto temp=root->serach(text,i+1);\n           if(temp.first!=\'0\' && temp.second<n && text[temp.second]==\';\') \n           {\n               res.push_back(temp.first);\n               i=temp.second+1;\n               continue;\n           }\n        }\n        \n        res.push_back(text[i]);\n        i++;\n    }\n    return res;\n    }\n};\n```\n\n**Upvote+= "Found Helpful" ? 1:0;\nAny suggestions ,plz drop it it will improve my skill;**
['C']