C++ solution similar to twoSum 100% fast
\nclass Solution {\npublic:\n    bool starts_with(string_view target, string_view nums){\n        if(nums.size()>target.size()) return false;\n        for(int i
```\nclass Solution {\npublic:\n    bool starts_with(string_view target, string_view nums){\n        if(nums.size()>target.size()) return false;\n        for(int i = 0;i<nums.size();i++)\n            if(nums[i]!=target[i]) return false;\n        \n        return true;\n    }\n    bool half_equal(string_view target){\n        if(target.size()%2!=0) return false;\n        int n = target.size()/2;\n        for(int i = 0;i<n;i++){\n            if(target[i]!=target[i+n]) return false;\n        }\n        return true;\n    }\n    int numOfPairs(vector<string>& nums, string target) {\n        int res = 0;\n        unordered_map<string, int> freq;\n        for(const auto& num: nums)\n            freq[num]++;\n        \n        int flag = half_equal(target);\n        string half {target.begin(), target.begin()+target.size()/2};\n        if(flag){\n            if(freq.find(half)!=freq.end()){\n                int n = freq[half];\n                res+= n*(n-1);\n            }\n        }\n        for(int i = 0;i<nums.size();i++){\n            if(!flag || nums[i]!=half){\n                if(!starts_with(target, nums[i])) continue;\n                \n                // stoi(target) - stoi(nums[i])\n                string rest {target.begin()+nums[i].size(), target.end()};\n                if(freq.find(rest)!=freq.end())\n                    res+=freq[rest];\n            }\n        }\n        return res;\n    }\n};\n```
['C']