(C++) 2023. Number of Pairs of Strings With Concatenation Equal to Target
\n\nclass Solution {\npublic:\n    int numOfPairs(vector<string>& nums, string target) {\n        unordered_map<string, int> freq; \n        for (auto& x : nums
\n```\nclass Solution {\npublic:\n    int numOfPairs(vector<string>& nums, string target) {\n        unordered_map<string, int> freq; \n        for (auto& x : nums) freq[x]++; \n        \n        int ans = 0; \n        for (auto& [k, v] : freq) \n            if (target.substr(0, k.size()) == k) {\n                string suffix = target.substr(k.size()); \n                ans += v * freq[suffix];\n                if (k == suffix) ans -= freq[suffix]; \n            }\n        return ans; \n    }\n};\n```
['C']