Simple | Elegant | Clever | Optimum
Success\nDetails \nRuntime: 58 ms, faster than 81.66% of Python3 online submissions.\nMemory Usage: 14 MB, less than 68.18% of Python3 online submissions.\n\n1.
Success\nDetails \nRuntime: 58 ms, faster than **81.66%** of Python3 online submissions.\nMemory Usage: 14 MB, less than **68.18%** of Python3 online submissions.\n\n1. Creat a hashmap for elements in nums as a key with the frequency of occurence as a value.\n\n2. Itterate over nums: if the current element is equal to the first half of the target AND the remaining half is present in the hashmap then increment if count by the frequency of that remainig part.\n\n3. if the current element is euqal to the remaing half then decrement the count by one. We do this to avoid the pairing of the current element with itself. \n\n***If this helps, Leave an upvote !!!***\n\n```\nclass Solution:\n    def numOfPairs(self, nums: List[str], target: str) -> int:\n        d={}\n        for i in nums:\n            if i in d:\n                d[i]+=1\n            else:\n                d[i]=1\n        c=0\n        for i in nums:\n            if i ==target[:len(i)] and target[len(i):] in d:\n                c=c+d[target[len(i):]]\n                if i == target[len(i):]:\n                    c=c-1\n        return c\n```
['Python']