[Python 3] HashTable || Commented and Explained
\tdef numOfPairs(self, nums: List[str], target: str) -> int:\n\t\t\t# Creating a dictionary for storing the frequency of every string in nums \n\t\t\tmyDict = c
\tdef numOfPairs(self, nums: List[str], target: str) -> int:\n\t\t\t# Creating a dictionary for storing the frequency of every string in nums \n\t\t\tmyDict = collections.Counter(nums)\n\t\t\tcount = 0\n\t\t\t\n\t\t\tfor i in nums:\n\t\t\t\t# Finding a substring without the current element\n\t\t\t\t# Point to be noted: replace only ONCE thats why the count in replace method is set to 1\n\t\t\t\tsub = target.replace(i,"",1)\n\t\t\t\t\n\t\t\t\t# Check if the substring obtained is in the dictionary or not\n\t\t\t\tif myDict.get(sub,None) != None:\n\t\t\t\t\n\t\t\t\t\t# To check for same elements that adds upto the target element Eg: "1"+"1" = "11"\n\t\t\t\t\tif sub == i:\n\t\t\t\t\t\t# If same element then we add total frequency of that element-1 as it indexes should be different\n\t\t\t\t\t\tcount += myDict[sub]-1\n\t\t\t\t\telse:\n\t\t\t\t\t\t# If the current element and substring forms the target string then we add the frequency of the substring as the current element will form that many pairs\n\t\t\t\t\t\tif (i+sub)==target:\n\t\t\t\t\t\t\tcount += myDict[sub]\n\t\t\t# Returning the final count \n\t\t\treturn count\n\n\n![image](https://assets.leetcode.com/users/images/8b57c7c2-67eb-473d-9940-f6b3ad6325f4_1633202940.776434.png)\n\nPlease **UPVOTE** if you like my solution, it motivates me a lot!
['Hash Table', 'Python3']