🤯 95% fast | Counter based easy python solution | Explained
Logic is we calculate the number of unique words in nums using counter. We then form all prefix and suffix pairs of  the target and check if they are in the dic
Logic is we calculate the number of unique words in nums using counter. We then form all prefix and suffix pairs of  the target and check if they are in the dict or not. If they are present we multiply their counts and add it to ans. \n**Edge case: if pref and suff are equal, we have to multiply count * (count - 1), since we cant the same pref/suff more than once.**\n\nUpvote if you understood the logic :)\n\n```\nclass Solution:\n    def numOfPairs(self, nums: List[str], target: str) -> int:\n        mem = Counter(nums)\n        ans = 0\n        \n        for i in range(1,len(target)):\n            pref = target[:i]\n            suff = target[i:]\n            x = y = 0\n            \n            if pref == suff and pref in mem:\n                x = mem[pref]\n                y = x - 1\n            else:                \n                if pref in mem:\n                    x = mem[pref]\n                else:\n                    continue\n                if suff in mem:\n                    y = mem[suff]\n                else:\n                    continue\n\n            ans += (x*y)\n\n        return ans\n```
['Suffix Array', 'Python']