C#, time: O(n), space: O(n)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n- count each string app
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- count each string appearances and store in the dictionary\n- split target into two strings and see if we can find both in the dictionary\n- if both strings are in the dictionary, number of pairs are simply all possible combinations with i = j\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n# Code\n```\npublic class Solution {\n    public int NumOfPairs(string[] nums, string target) {\n        Dictionary<string, int> dict = nums.GroupBy(s => s).ToDictionary(group => group.Key, group => group.Count());\n        int pairs = 0;\n\n        for(int i = 1; i < target.Length; i++)\n        {\n            string s1 = target.Substring(0, i);\n            string s2 = target.Substring(i);\n\n            if (dict.ContainsKey(s1) && dict.ContainsKey(s2))\n            {\n                // cannot use string with same index\n                pairs += dict[s1] * (s1 == s2? (dict[s2] - 1) : dict[s2]);\n            }\n        }\n\n        return pairs;\n    }\n}\n```
['C#']