[C++] Simple C++ Code
\n# If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\npubli
\n# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\npublic:\n    int numOfPairs(vector<string>& nums, string target) {\n        unordered_map<string, int> um;\n        int n = target.size();\n        for(string &str : nums)\n            um[str]++;\n        int ans = 0;\n        string p1 = "", p2;\n        for(int i = 0; i < n; i++)\n        {\n            //cout << i << " ";\n            p1 += target[i];\n            p2 = target.substr(i+1);\n            //cout << p1 << " " << p2 << endl;\n            if(p1 == p2)\n            {\n                if(!um.count(p1))\n                    continue;\n                int val = um[p1];\n                ans += val*(val-1);\n            }\n            else\n            {\n                if(um.count(p1) && um.count(p2))\n                {\n                    int val1 = um[p1], val2 = um[p2];\n                    ans += val1*val2;   \n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']