c++ Tuple
find function explanation : \n\nstring  s = "abcdef";\ncout << s.find("ef"); //  -> 4;\n/*if not fount then it will return 18446744073709551615 which is equas t
**find function explanation :** \n```\nstring  s = "abcdef";\ncout << s.find("ef"); //  -> 4;\n/*if not fount then it will return 18446744073709551615 which is equas to string::npos */\nanother case :\nstring s = "abcabcabc";\ns.find("ab",0); -> it will find string "ab" from index 0);\nsuppose s.find("ab",1) -> 3\n```\n**replace function explanation :**\n```\nstring str1 ="This is Cpp language"  \nstring str2= "java";  \nstr1.replace(8,3,str2);\ncout<<str1; //This is java language\n```   \n\n***passed 155 test cases out of 158***\n![image](https://assets.leetcode.com/users/images/e622b2c2-b6c4-4c41-8542-f5ac5dd57778_1655966675.3045042.png)\n\n**don\'t submit this code :**\n```\nclass Solution {\npublic:\n    string entityParser(string text) {\n        vector<pair<string,char>> parser = {{"&quot;",\'\\"\'},{"&apos;",\'\\\'\'},{"&amp;",\'&\'},{"&gt;",\'>\'},{"&lt;",\'<\'},{"&frasl;",\'/\'}};\n        \n        for(auto it : parser){\n            int start = 0;\n            string str = it.first;\n            int n = size(str);\n            while(true){\n                int idx = text.find(str,start);\n                if(idx != string::npos){\n                    string s = string(1,it.second);\n                    text.replace(idx,n,s);\n                    start = idx;\n                }\n                else break; \n            }\n        }\n        return text;\n    }\n};\n```\n*so in this test case -> ```"&amp;amp;"``` -> this code convert ```&amp; to &``` and the string will be ```&amp;``` and the final output is ```&``` .* **so i have to count the frequency of eatch parser of the given string and that many time for eatch parser i have to perform the replace operation .** \n\n\n\n\n**So here i used tuple to store the frequency as well** \n\n```\nclass Solution {\npublic:\n    string entityParser(string text) {\n        vector<tuple<string,char,int>> parser = {{"&quot;",\'\\"\',0},{"&apos;",\'\\\'\',0},{"&amp;",\'&\',0},{"&gt;",\'>\',0},{"&lt;",\'<\',0},{"&frasl;",\'/\',0}};\n\t\t/* Small Note how access tuple\'s elements :\n\t\t   tuple<int,string,char> myTuple = {369,"aniket",\'b\'};\n\t\t   to access ith  element get<i>(myTuple);\n\t\t*/\n\t\t//this for loop will stroe the freqency of every parser\n        for(auto& it : parser){\n            int start = 0;\n            string str = get<0>(it);\n            int cnt = 0;\n            while(true){\n                int idx = text.find(str,start);\n                if(idx != string::npos){ \n                    cnt++;\n                    start = idx+1;\n                }\n                else break; \n            }\n            get<2>(it) = cnt;\n        }\n        \n\t\t/*just find the parser if it is presnt just perform the replace operation according frequency \n\t\t(how many time it  occurs in the text to avoid previous output . . . . */\n        for(auto& it : parser){\n            int cnt = get<2>(it);\n            if(!cnt) continue;\n            else{\n                int start = 0;\n                string str = get<0>(it);\n                int n = size(str);\n                while(cnt--){\n                    int idx = text.find(str,start);\n                    if(idx != string::npos){\n                        string s = string(1,get<1>(it));\n                        text.replace(idx,n,s);\n                        start = idx;\n                    }\n                }     \n            }  \n        }\n        \n        return text;\n    }\n};\n```\n\n**If learn something new and it\'s helpful please upvote and any doubt , do comment :)**
['C', 'C++']