C++ Unordered Map Solution
Go through every string and check if its a substring of the target. If yes, search for the remaining substring from the target from the map we\'ve built upfront
Go through every string and check if its a substring of the target. If yes, search for the remaining substring from the target from the map we\'ve built upfront that tells us where(index) each string was found.\n\n```\nclass Solution {\npublic:\n    int numOfPairs(vector<string>& nums, string target) {\n        std::unordered_map<std::string, std::vector<int>> strings;\n        \n        for(size_t i = 0; i < nums.size(); i++) {\n            strings[nums[i]].push_back(i);\n        }\n        size_t total = 0;\n        for(size_t i = 0; i < nums.size(); i++) {\n            if (target.compare(0, nums[i].size(), nums[i]) == 0) {\n                std::string remaining = target.substr(nums[i].size());\n                auto count_it = strings.find(remaining);\n                if (count_it != strings.end()) {\n                    total += count_it->second.size();\n                    // If the string pairs are identical, we should eliminate (i,i) kind of pairs\n                    // since the problem states that i != j\n                    if (remaining == nums[i]) {\n                        total--;\n                    }\n                }\n            }\n        }\n        \n        return total;\n    }\n};\n```\n\nTime Complexity = `O(MN)` where `M` is the average string length of the given strings and `N` is the total number of strings.\nSpace Complexity = `O(N)`
[]